Prevent the pathname setter from erasing the path of path-only URLs, …#582
Prevent the pathname setter from erasing the path of path-only URLs, …#582annevk merged 2 commits intowhatwg:mainfrom
Conversation
…as that would make them cannot-be-a-base URLs.
annevk
left a comment
There was a problem hiding this comment.
Thanks for spotting this, this does look like a somewhat serious oversight.
|
|
||
| <li><p>Otherwise, if <var>state override</var> is given and <var>url</var>'s | ||
| <a for=url>host</a> is null, <a for=list>append</a> the empty string to <var>url</var>'s | ||
| <a for=url>path</a> |
There was a problem hiding this comment.
Why only when host is null? It seems this needs to generally happen.
There was a problem hiding this comment.
Because non-special URLs with a host (e.g. foo://somehost) can have an empty string as a path. The issue is limited to path-only URLs.
|
Editorially LGTM and matches the tests and jsdom/whatwg-url implementation. In terms of interop and implementation alignment, of the three tests added in web-platform-tests/wpt#27720:
Should we consider changing the spec for test 2? I don't have a strong intuition on the model here though so maybe there's a reason that would be bad. |
|
Chrome and Firefox still don't have non-special URLs implemented correctly so I rather not count them. Safari doesn't seem to allow for removal of the path if there is a host for non-special URLs. I tend to side with OP that it should be possible. That is, if |
|
I think it is valid (or, well, not disallowed) for some particular schemes/application to treat an empty path differently from a "/" path. For instance if you're connecting to a remote server: for some hypothetical scheme, |
|
@achristensen07 any thoughts on this? |
|
It looks like this PR only changes the behavior of test 3 in web-platform-tests/wpt#27720, and Safari already implements the new behavior for test 3. @annevk, would this be enough to count as implementer interest? |
|
I would still prefer to wait for @achristensen07 or someone else from WebKit to weigh in as test 2 does require implementation changes. |
|
I haven't gone through the setters like I have the constructor. I think test 2 shows a bug in WebKit that I'm willing to try to change. NSURLComponents already has the behavior that would make test 2 pass, and parsing foo://somehost doesn't add a slash to the path, so I think the path setter shouldn't either, unless called with something that isn't empty and doesn't start with a slash. |
|
Thanks @achristensen07! @karwa can you file a bug against WebKit for that? I don't think we need bugs for Chrome/Firefox as they haven't yet caught up here. |
|
I filed nodejs/node#39059 on Node.js. |
|
Thanks @karwa for finding and fixing this! 🎉 |
For whatwg/url#582. Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
…have their paths erased by th…, a=testonly Automatic update from web-platform-tests URL: pathname setter should not erase path-only URL paths For whatwg/url#582. Co-authored-by: Anne van Kesteren <annevk@annevk.nl> -- wpt-commits: 77d54aa9e0405f737987b59331f3584e3e1c26f9 wpt-pr: 27720
…have their paths erased by th…, a=testonly Automatic update from web-platform-tests URL: pathname setter should not erase path-only URL paths For whatwg/url#582. Co-authored-by: Anne van Kesteren <annevk@annevk.nl> -- wpt-commits: 77d54aa9e0405f737987b59331f3584e3e1c26f9 wpt-pr: 27720
…have their paths erased by th…, a=testonly Automatic update from web-platform-tests URL: pathname setter should not erase path-only URL paths For whatwg/url#582. Co-authored-by: Anne van Kesteren <annevk@annevk.nl> -- wpt-commits: 77d54aa9e0405f737987b59331f3584e3e1c26f9 wpt-pr: 27720
…as that would make them cannot-be-a-base URLs.
Fixes #581
JSDom patch: jsdom/whatwg-url#178
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff