This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26387 - file: Map "localhost" to empty host in file: URLs?
Summary: file: Map "localhost" to empty host in file: URLs?
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: URL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+urlspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-19 13:53 UTC by Simon Sapin
Modified: 2015-08-13 09:37 UTC (History)
2 users (show)

See Also:


Attachments

Description Simon Sapin 2014-07-19 13:53:12 UTC
http://tools.ietf.org/html/rfc1738#section-3.10 (which is the closest I found to defining the file: scheme) says:

> As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as `the machine from which the URL is being interpreted'.

Since file://localhost/foo and file:///foo are equivalent, it seems preferable that they parse the same.

In the file host state, after
> Otherwise, if buffer is the empty string, set state to relative path start state.

… consider adding
> Otherwise, if buffer is "localhost", set buffer to the empty string, and state to relative path start state.
Comment 1 Anne 2014-07-27 17:54:52 UTC
Per testing I seem to remember this only happened in rebel Opera.
Comment 2 Anne 2015-06-15 14:56:16 UTC
This also happens in Firefox seemingly.
Comment 3 Anne 2015-08-13 09:37:30 UTC
Internet Explorer does this too. 

I ended up fixing this slightly differently from how you suggested since we also need to account for the input here being case-insensitive so I've just deferred to the host parser.

https://github.com/whatwg/url/commit/bb36bd9f035be2e3904ddc8e4e8fd1e756ae8f1e