-
Notifications
You must be signed in to change notification settings - Fork 30k
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.format does not postfix slashes to protocol but doc pretend it should by default #3361
Comments
Just pasting what I had found here, as I had created a duplicate issue. If you look at https://github.com/nodejs/node/blob/master/lib/url.js you see:
So the documented behaviour only happens when host/hostname are set.
|
Change url.format's references to slash postfixing to reflect true behaviour (it only automatically postfixes slashes to the slashedProtocols when host is present). Fixes: nodejs#3361
Hmm, I'd say this is worth a breaking change as a file uri without |
To be sure we're ok on the desired end result, this test would currently fail :
(in More sensible solution would be to have something specific to protocols that don't have a hostname but still want slashes. A bit like the way Or did I miss something? |
Hmm, that's an unexpected failure. Unfortunately, I'm not really familiar with that code. I agree that a failure like this is unacceptable. By the way, we have #2303 which is pretty much a rewrite of the module for perf reasons, which also contains a few breaking changes. If a fix for this turns out to be too complicated, maybe it's better to incorporate it there. |
Reopened because 2a29b70 does not take care of the issue, it just documents the current behaviour. |
Change url.format's references to slash postfixing to reflect true behaviour (it only automatically postfixes slashes to the slashedProtocols when host is present). Fixes: #3361 PR-URL: #4119 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Change url.format's references to slash postfixing to reflect true behaviour (it only automatically postfixes slashes to the slashedProtocols when host is present). Fixes: #3361 PR-URL: #4119 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Change url.format's references to slash postfixing to reflect true behaviour (it only automatically postfixes slashes to the slashedProtocols when host is present). Fixes: #3361 PR-URL: #4119 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Change url.format's references to slash postfixing to reflect true behaviour (it only automatically postfixes slashes to the slashedProtocols when host is present). Fixes: nodejs#3361 PR-URL: nodejs#4119 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
https://url.spec.whatwg.org/#url-syntax indicates that all special schemes ( So it seems that any URL generated with those schemes specified should include |
`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
Quoting the doc :
But a quick test (using nodejs V4.1) show the problem:
Output : file:/home/user. While the expected output is : file:///home/user
Setting
uri.slashes = true
make it format the correct URL.I think it's not worth it to modify the module itself as it's stable. However the doc should be updated to reflect this behaviour.
Should I submit a PR reflecting this?
The text was updated successfully, but these errors were encountered: