-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: update the processing in the scheme state. #11887
Conversation
cc @nodejs/url |
The returning is handled in the JS layer. You might want to update that instead. |
Oh that's nice. I will update the commit then! |
af99bab
to
1edd461
Compare
@TimothyGu I've updated the commits to handling it in JS layer. Well, I'm not sure those steps should be handled in the scheme state or not, but at least the spec expects it as scheme state checking. What are your thoughts on? |
lib/internal/url.js
Outdated
@@ -133,6 +133,12 @@ function onParseProtocolComplete(flags, protocol, username, password, | |||
if ((s && !newIsSpecial) || (!s && newIsSpecial)) { | |||
return; | |||
} | |||
if (protocol === 'file:' && (username || password || port > -1)) { |
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.
port
can only be >= 0
or undefined
, since the C++ layer sets port
to undefined if it is -1
, and you should probably check ctx.username
and ctx.password
instead of username
and password
since IIRC the C++ layer doesn't pass those into the callback if it's unneeded.
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.
Good catch. +1
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.
That's right! I will update it. Thanks 😺
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.
Ok, I've updated.
1edd461
to
6ccf827
Compare
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 other than the nit.
lib/internal/url.js
Outdated
@@ -133,6 +133,14 @@ function onParseProtocolComplete(flags, protocol, username, password, | |||
if ((s && !newIsSpecial) || (!s && newIsSpecial)) { | |||
return; | |||
} | |||
if (protocol === 'file:' && | |||
(ctx.username || ctx.password || ctx.port !== undefined) | |||
) { |
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.
nit: stylistically it's more common to write it as:
if (protocol === 'file:' &&
(ctx.username || ctx.password || ctx.port !== undefined)) {
Since file URLs can not have `username/password/port`, the specification was updated to restrict setting protocol to "file". Refs: whatwg/url#269 Fixes: nodejs#11785
Synchronize url-setter-test to upstream. Refs: web-platform-tests/wpt#5112
6ccf827
to
18eebe9
Compare
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.
If there are test cases that don't pass at the moment, you can change url-setter-tests.json
to a js file with module.exports
, then put those test cases in that file and comment them out, like what https://github.com/nodejs/node/blob/master/test/fixtures/url-tests.js does
@joyeecheung that's nice! I will sync the setter url fixture in my next patch, will rename the file at the same time then :) |
Since file URLs can not have `username/password/port`, the specification was updated to restrict setting protocol to "file". Refs: whatwg/url#269 Fixes: #11785 PR-URL: #11887 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Synchronize url-setter-test to upstream. Refs: web-platform-tests/wpt#5112 PR-URL: #11887 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Since file URLs can not have `username/password/port`, the specification was updated to restrict setting protocol to "file". Refs: whatwg/url#269 Fixes: nodejs#11785 PR-URL: nodejs#11887 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Synchronize url-setter-test to upstream. Refs: web-platform-tests/wpt#5112 PR-URL: nodejs#11887 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Since file URLs can not have `username/password/port`, the specification was updated to restrict setting protocol to "file". Refs: whatwg/url#269 Fixes: #11785 PR-URL: #11887 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Synchronize url-setter-test to upstream. Refs: web-platform-tests/wpt#5112 PR-URL: #11887 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Updates: + Bring tests url-setter-tests from WPT, and put it as JavaScript + Comment out unpassed tests Refs: web-platform-tests/wpt#5112 Refs: nodejs#11887
Refs: web-platform-tests/wpt#4586 Refs: #11887 PR-URL: #12058 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Updates: + Bring tests url-setter-tests from WPT, and put it as JavaScript + Comment out unpassed tests Refs: web-platform-tests/wpt#5112 Refs: #11887 PR-URL: #12058 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Updates: + Bring tests url-setter-tests from WPT, and put it as JavaScript + Comment out unpassed tests Refs: web-platform-tests/wpt#5112 Refs: nodejs#11887 PR-URL: nodejs#12058 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
PR-URL: nodejs#12507 Refs: web-platform-tests/wpt#4586 Refs: nodejs#11887 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #12507 Refs: web-platform-tests/wpt#4586 Refs: #11887 Reviewed-By: James M Snell <jasnell@gmail.com>
Fix #11785. I've updated the processing in the scheme state to follow the specification and synchronized
url-setter-tests
with upstream.https://github.com/whatwg/url/blob/a8ed8d2aefeec1e742490d08844c3d91a87e77fb/url.bs#L1493-L1508
While I was testing added tests, I noticed that the current state machine of Node.js doesn't parse URL correctly for
pathname
. For example:So I got rid of the following test for this time.
I will work on it later.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
url, test