getUrlsFromQueryParams incompatible with URL missing protocol (e.g. //sindresorhus.com) #42
michelnev posted onGitHub
Starting with the following call:
let text = 'Lorem ipsum dolor sit amet, //sindresorhus.com consectetuer adipiscing http://yeoman.io elit.'
let urlsSet = getUrls( text,
{
'stripAuthentication': true,
'stripHash': true,
'sortQueryParameters': true,
'stripWWW': false,
'extractFromQueryString': true
} );
The following exception will get thrown:
Failed to get urls from buffer { TypeError [ERR_INVALID_URL]: Invalid URL: //sindresorhus.com at onParseError (internal/url.js:219:17) at parse (internal/url.js:228:3) at new URL (internal/url.js:311:5) at getUrlsFromQueryParams (/src/yoyo/nevelex_nodered/node_modules/get-urls/index.js:8:26) at module.exports (/src/yoyo/nevelex_nodered/node_modules/get-urls/index.js:35:24) at Function.getUrlsFromBuffer (/src/yoyo/nevelex_nodered/UrlParser.js:152:27) at Context.<anonymous> (/src/yoyo/nevelex_nodered/test/UrlParser_test.js:292:24) at callFnAsync (/src/yoyo/node_modules/mocha/lib/runnable.js:400:21) at Test.Runnable.run (/src/yoyo/node_modules/mocha/lib/runnable.js:342:7) at Runner.runTest (/src/yoyo/node_modules/mocha/lib/runner.js:455:10) at /src/yoyo/node_modules/mocha/lib/runner.js:573:12 at next (/src/yoyo/node_modules/mocha/lib/runner.js:369:14) at /src/yoyo/node_modules/mocha/lib/runner.js:379:7 at next (/src/yoyo/node_modules/mocha/lib/runner.js:303:14) at /src/yoyo/node_modules/mocha/lib/runner.js:342:7 at done (/src/yoyo/node_modules/mocha/lib/runnable.js:319:5) at callFn (/src/yoyo/node_modules/mocha/lib/runnable.js:395:7) at Hook.Runnable.run (/src/yoyo/node_modules/mocha/lib/runnable.js:364:7) at next (/src/yoyo/node_modules/mocha/lib/runner.js:317:10) at Immediate.<anonymous> (/src/yoyo/node_modules/mocha/lib/runner.js:347:5) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5) input: '//sindresorhus.com' }