urlfile-uri

Meaning of '///' after 'file:' protocol (URL)


Why does file: protocol has 3 (back)slashes in this URL?

file:///C:/Users

(C:/Users is the path name of this URL.)

How does an URL parser handle it?


I thought the last slash of these 3 slashes could mean 'path', I put a host name before declaring it, like

file://domainname.extension/C:/Users

but JavaScript's URL parser ignores this domain name.


Solution

  • To make things easier to understand, here file:// is the protocol and / is the root directory.

    And later occurring terms are subdirectory, as in http://google.com: here http:// is the protocol and google.com is the root directory.

    This is a URI scheme, typically used to retrieve files from within one's own computer.

    For more details, see https://en.wikipedia.org/wiki/File_URI_scheme