Skip to content

Preserve "localhost" in file URLs? #618

Open
@karwa

Description

@karwa

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 (so that file:///SomeShare can actually be resolved). Both are kind of reasonable, I suppose.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions