new URL('file://localhost').href should be 'file:///', not 'file://localhost/' |
|||
Issue descriptionAccording to the URL spec, if the host-part of a URL with 'file' scheme is 'localhost', the host-part should be omitted. (https://url.spec.whatwg.org/#concept-basic-url-parser) file host state - If c is EOF code point, "/", "\", "?", or "#", decrease pointer by one, and run these substeps: - If buffer is a Windows drive letter, syntax violation, set state to path state. - Otherwise, if buffer is the empty string, set state to path start state. - Otherwise, run these steps: - Let host be the result of host parsing buffer. - If host is failure, return failure. - If host is not "localhost", set url’s host to host. - Set buffer to the empty string and state to path start state. - Otherwise, append c to buffer. Spec issue: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26387 Spec commit: https://github.com/whatwg/url/commit/bb36bd9f035be2e3904ddc8e4e8fd1e756ae8f1e
,
Feb 6 2017
That seems like the right place to add the logic, assuming other browsers follow along. CCing Anne, though, as it's not clear to me why we'd special-case `localhost`. Why not loopback addresses, which would seem to have the same behavior? `127.0.0.1`, `[::1]`, etc? *shrug* `file:` is weird. :(
,
Feb 7 2017
Does Edge normalize loopback addresses away?
,
Feb 7 2017
With Microsoft Edge 38.14393.0.0:
> new URL('file://localhost').href
"file:///"
> new URL('file://example').href
"file://example/"
> new URL('file://127.0.0.1').href
"file://127.0.0.1/"
,
Feb 13 2017
Anne: friendly ping
,
Feb 13 2017
Sorry, I didn't realize you were waiting for me. Given that Edge only does this for localhost, I don't really see a reason to do it for the others. Also, do we know for a fact that those would have identical behavior? Also, please study https://github.com/whatwg/url/issues/232 (and ideally give feedback) as it's related to this. It seems Chrome has problems either way with the stripping of leading slashes, but this might make it worse if not done carefully (and even then I'm not sure how to solve the pathname setter issue I just added).
,
Feb 8 2018
|
|||
►
Sign in to add a comment |
|||
Comment 1 by yhirano@chromium.org
, Feb 6 2017