-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent the pathname setter from erasing the path of path-only URLs, … #582
Conversation
…as that would make them cannot-be-a-base URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this, this does look like a somewhat serious oversight.
url.bs
Outdated
|
||
<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only when host is null? It seems this needs to generally happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@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 <[email protected]>
…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 <[email protected]> -- 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 <[email protected]> -- 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