New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 688961 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 660384
issue 682149



Sign in to add a comment

new URL('file://localhost').href should be 'file:///', not 'file://localhost/'

Project Member Reported by yhirano@chromium.org, Feb 6 2017

Issue description

According 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
 
mkwst@, I'd like to add the logic to src/url/url_parse_file.cc. Are you happy with the idea?

Thanks!

Comment 2 by mkwst@chromium.org, Feb 6 2017

Cc: annevank...@gmail.com
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. :(

Does Edge normalize loopback addresses away?
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/"

Anne: friendly ping
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).
Blocking: 660384

Sign in to add a comment