Repository navigation
custom protocol parse result is different from chrome and firefox #44476
Description
Activity
- changed the title
[-]custom protocol parse result pathname is different from chrome and firefox[/-][+]custom protocol parse result is different from chrome and firefox[/+]on Sep 1, 2022 whatwg-urlseems to behave the same as Node.js, so it looks like a bug in web browsers?- addedwhatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
on Sep 1, 2022 whatwg-urlseems to behave the same as Node.js, so it looks like a bug in web browsers?I haven't looked closely, but there's also something in the spec about how browser implementations are supposed to do more steps than non-browser implementations, so the difference in behavior might be due to that.
Non-web-browser implementations only need to implement the basic URL parser.
I haven't looked at the steps in the parser to determine if this is or isn't a bug, but there is a good chance this is an expected divergence between web browsers and non-web-browsers.
@nodejs/url
Deno and Safari 15.6.1 work like the Node.js and the reference implementation of the WHATWG URL.
$ deno Deno 1.25.0 exit using ctrl+d or close() > new url("sindre://www.sorhus.com") URL { href: "sindre://www.sorhus.com", origin: "null", protocol: "sindre:", username: "", password: "", host: "www.sorhus.com", hostname: "www.sorhus.com", port: "", pathname: "", hash: "", search: "" } >I think Chrome and Firefox are deviating from the spec for some reason.
Reacted by Tobias NießenReacted by Daniel Regeci, Maksim Shmakov, Sasha and Kainoa KanterI think it is Chrome, Edge, and Firefox are deviating from the spec because they both fail the wpt test when parsing custom protocols like
sc://:- go to https://wpt.fyi/results/url/url-constructor.any.html?label=master&label=experimental&aligned&view=subtest
- search "Parsing: <sc://" and you will see all 22 tests parsing "sc://" failed in Chrome, Edge, and Firefox, but are passed in Safari.
Version
v18.7.0 v16.16.0
Platform
alpinelinux and archlinux
Subsystem
No response
What steps will reproduce the bug?
Node
Google Chrome 92
Mozilla Firefox 90
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
Additional information
Related background story issue
sindresorhus/normalize-url#140
sindresorhus/normalize-url#147
Related background story
To answer Can I use version 7 in the browser?
I fork sindresorhus/normalize-url to loynoir/normalize-url
In that fork, I added real browser test using karma.
And found browser falling case, but it's ok in node
Seems root cause is
Node
Google Chrome 92
Mozilla Firefox 90