-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
url: trim leading slashes of file URL paths #12203
Conversation
"search": "", | ||
"hash": "" | ||
}, | ||
// { |
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.
Is this commented text necessary?
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.
This additional is to follow the spec/test updates(web-platform-tests/wpt#5195), and we're still having some remaining unfollowed updates of the spec. When we follow them that can fix this test cases, we can take the comment out.
e.g.
node/test/fixtures/url-setter-tests.js
Lines 373 to 380 in 843b7e6
// { | |
// "href": "file://test/", | |
// "new_value": "test", | |
// "expected": { | |
// "href": "file://test/", | |
// "username": "" | |
// } | |
// } |
I will work on it later, but I think it's better to separate a patch from this PR since the referral link can be different.
(ch == kEOL || | ||
ch == '?' || | ||
ch == '#')) { | ||
while (url->path.size() > 1 && url->path[0].length() == 0) { |
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.
Did you mean > 0
here?
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.
The updated spec says greater than 1
instead of > 0
:
https://github.com/whatwg/url/blob/2f4b7f74533398c41f4316157f027a33a627caf9/url.bs#L2070
cc @nodejs/url |
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.
Almost there.
src/node_url.cc
Outdated
url->flags |= URL_FLAGS_HAS_PATH; | ||
url->path.push_back(base->path[0]); | ||
if (NORMALIZED_WINDOWS_DRIVE_LETTER(base->path[0])) { |
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.
The url->flags |= URL_FLAGS_HAS_PATH;
should go into this branch.
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! The flags seem to be there around passing a value to the property.
Updates :)
src/node_url.cc
Outdated
url->path.push_back(base->path[0]); | ||
if (NORMALIZED_WINDOWS_DRIVE_LETTER(base->path[0])) { | ||
url->path.push_back(base->path[0]); | ||
} else { |
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.
And this branch needs a url->flags |= URL_FLAGS_HAS_HOST;
3209da9
to
56e52d5
Compare
@@ -1620,6 +1620,33 @@ module.exports = | |||
"href": "sc://example.net/%23", | |||
"pathname": "/%23" | |||
} | |||
}, | |||
{ | |||
"comment": "File URLs and (back)slashes", |
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.
Can you update the hash of the link in the comment at the top of this file
/* WPT Refs:
https://github.com/w3c/web-platform-tests/blob/e48dd15/url/setters_tests.json
License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
*/
This should be 3eff1bd now.
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.
updated it to 3eff1bd
@@ -5110,6 +5110,246 @@ module.exports = | |||
"search": "?test", | |||
"hash": "#x" | |||
}, | |||
"# File URLs and many (back)slashes", |
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.
Ditto, although this file is missing https://github.com/w3c/web-platform-tests/blob/3eff1bd564a0085347d31d80fbee13aaa2e3c2ca/url/urltestdata.json#L5380-L5451 ?
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.
Done synchronising them all by hands, and the lines were added as a result! thanks.
5720d56
to
50f48b6
Compare
It should trim the slashes after the colon into three for file URL. Refs: web-platform-tests/wpt#5195 Fixes: nodejs#11188
50f48b6
to
5d0f60d
Compare
The windows-fanned failure looks unrelated. |
Yep failed test on windows because of #12283, CI can be considered green. |
Another one for good luck |
@refack Thanks for following up! I'm going to merge this tonight :) |
Landed in b470a85. Thanks! |
It should trim the slashes after the colon into three for file URL. PR-URL: #12203 Refs: web-platform-tests/wpt#5195 Fixes: #11188 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
cc @watilde |
It should trim the slashes after the colon into three for file URL.
Resources:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
url