HTTP starts with two slashes. E.g. http://example.com
.
Same goes for FTP. E.g. ftp://example.com
.
However, file "URLs" start with three slashes. E.g. Reading a pdf file using chrome, the URL would be file:///D:/Desktop/Book.pdf
.
Why do file URLs use three slashes?
Answer
As others have mentioned, the file schema is in the form "file://
All things being equal, the triple slash and "localhost" keyword only exist to ensure conformance with valid URI/URL syntax. In the context of the file schema, the host is meaningless since it loads directly from a filesystem without any explicit transfer protocol or server document path. Because it's not HTTP, it can't load from a standard web server where in theory you could have multiple local virtual hosts set up. And it can't load from a standard network volume that's technically another "host", since the browser just uses the volume name like "file:///volumes/foo". Finally, trying things like "file://example.com/some/file" doesn't work. There's probably some reason for supporting an external host, but I can't think of any.
The IETF is currently drafting changes to remove the triple-slash requirement, though the draft also adds a few oddball possibilities like file:c|/path
and even file://///host.example.com/path
.
https://tools.ietf.org/html/draft-ietf-appsawg-file-scheme-03
"3. This specification neither defines nor forbids a mechanism for accessing non-local files."
Comments
Post a Comment