-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: return valid file: urls fom url.format() #7234
Conversation
if (this.slashes || host) { | ||
if (pathname && pathname.charCodeAt(0) !== 47/*/*/) | ||
pathname = '/' + pathname; | ||
host = `//${host}`; |
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.
minor nit: last time i checked template strings had noticeable overhead, may need to check again on master 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.
Changed to string concatenation.
`file:` URLs that do not start with `file://` are invalid. Browsers convert `file:/etc/passwd` to `file:///etc/passwd`. This is also what the docs indicate we are doing, but we're not. Fixes: nodejs#3361
/cc @silverwind @claudiorodriguez (who had substantial comments on the issue this tries to address) |
LGTM if CI passes. |
I guess since it's semver-major and our docs say that semver-major changes need to be reviewed in some fashion by CTC: @nodejs/ctc |
Couple of unrelated-seeming issues on that first CI run. Here's a second one: https://ci.nodejs.org/job/node-test-commit/3707/ |
LGTM |
@jasnell This would seem to be orthogonal to nodejs/node-eps#28 but uh, just in case, care to review? |
pathname = '/' + pathname; | ||
host = '//' + host; | ||
} else if (protocol.length >= 4 && | ||
protocol.charCodeAt(0) === 102/*f*/ && |
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.
Nitpick: why not 0x.. instead?
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.
@indutny I used decimal because:
- It's decimal in most of the existing
charCodeAt()
calls, including ~10 lines later in lines 621 and 622, as well as theswitch
statement ~30 lines earlier starting on line 581. - The sample code (provided by @mscdex) used decimal and I did a lazy copy/paste.
I don't feel strongly about it, though, and I'm happy to change it to hex format if that's the difference between a quick LGTM
and a not-sure-about-this.
Trying to get more eyes on this... @nodejs/collaborators |
Adding |
For anyone here wondering what whatwg-url spec does, ref: https://url.spec.whatwg.org/#url-serializing. It always starts |
no objections from ctc |
`file:` URLs that do not start with `file://` are invalid. Browsers convert `file:/etc/passwd` to `file:///etc/passwd`. This is also what the docs indicate we are doing, but we're not. PR-URL: nodejs#7234 Fixes: nodejs#3361 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Brian White <[email protected]>
Landed in 336b027 |
Checklist
make -j4 test
(UNIX) orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
url
Description of change
file:
URLs that do not start withfile://
are invalid. Browsers convertfile:/etc/passwd
tofile:///etc/passwd
. This is also what the docs indicate we are doing, but we're not.Labeling
semver-major
because tests have to be updated for it.Fixes: #3361