normalize-url icon indicating copy to clipboard operation
normalize-url copied to clipboard

Error result when url using custom protocol in browser

Open loynoir opened this issue 2 years ago • 4 comments

Test in browser

https://github.com/sindresorhus/normalize-url/blob/3fb24bb03e340162b2e81d6145de8e4e5b3d6262/test.js#L40

Expected

normalizeUrl=(await import('https://cdn.jsdelivr.net/npm/[email protected]/index.js')).default
normalizeUrl('sindre://www.sorhus.com')
"sindre://www.sorhus.com"

Actual

normalizeUrl=(await import('https://cdn.jsdelivr.net/npm/[email protected]/index.js')).default
normalizeUrl('sindre://www.sorhus.com')
"sindre:/www.sorhus.com"

Related rejected fork

https://github.com/loynoir/normalize-url

loynoir avatar Aug 08 '21 14:08 loynoir

Related: Can I use version 7 in the browser? https://github.com/sindresorhus/normalize-url/issues/140

loynoir avatar Aug 08 '21 14:08 loynoir

Node

> new URL("sindre://www.sorhus.com").protocol
'sindre:'
> new URL("sindre://www.sorhus.com").host
'www.sorhus.com'
> new URL("sindre://www.sorhus.com").pathname
''

Google Chrome 92

> new URL("sindre://www.sorhus.com").protocol
"sindre:"
> new URL("sindre://www.sorhus.com").host
""
> new URL("sindre://www.sorhus.com").pathname
"//www.sorhus.com"

Mozilla Firefox 90

> new URL("sindre://www.sorhus.com").protocol
"sindre:"
> new URL("sindre://www.sorhus.com").host
""
> new URL("sindre://www.sorhus.com").pathname
"//www.sorhus.com"

loynoir avatar Aug 08 '21 20:08 loynoir

Google Chrome 92 chrome

Mozilla Firefox 90 firefox

loynoir avatar Aug 09 '21 08:08 loynoir

You should report this bug to https://github.com/nodejs/node if it's still an issue.

sindresorhus avatar Sep 01 '22 11:09 sindresorhus