[whatwg/url] Preserve "localhost" in file URLs? (#618)

Currently, this standard does not allow file URLs to have the hostname "localhost", instead replacing it with an empty hostname.

Unfortunately, while both an empty hostname and "localhost" refer to the local machine, they may imply different access patterns on Windows.

- For DOS-style paths (i.e. with drive letters), Chrome and Edge can resolve both `file:///C:/Windows` and `file://localhost/C:/Windows`.
- For UNC paths (i.e. with share names), Chrome and Edge can resolve `file://localhost/SomeShare` but fail to resolve `file:///SomeShare`.

There are 2 ways to resolve this: either we change the standard to preserve "localhost" and the implication that the URL may refer to a UNC path, or browsers will need to parse the first path component, detect whether or not it is a drive letter, and consider it a reference to a UNC local share if it isn't.

FWIW, the Windows shell APIs also get this wrong. If you call `GetFullPathName` (to normalize the path) followed by `UrlCreateFromPath`, it will also remove "localhost" and return a broken file URL.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/618

Received on Tuesday, 6 July 2021 04:47:47 UTC