I am using <a href="file:...">
links inside an Intranet for local folder access.
What bothers me is the amount of slashes I have to write in those URI for cross-browser compatibility.
Internet Explorer 11.904.16299.0
file://server/share/path/to/file ok
file:///server/share/path/to/file not working
file:////server/share/path/to/file ok
file://///server/share/path/to/file ok
Edge 41.16299.820.0
file://server/share/path/to/file ok
file:///server/share/path/to/file not working
file:////server/share/path/to/file ok
file://///server/share/path/to/file ok
Firefox 60.0 with Local Filesystem Links Extension
file://server/share/path/to/file not working
file:///server/share/path/to/file not working
file:////server/share/path/to/file not working
file://///server/share/path/to/file ok
When I look for answers in Stack Overflow or similar, I end up in those posts, saying that the correct amount is 3 slashes.
I write this question and answer it in case someone gets confused like I did.
It is important to distinct 2 types of <a href="file:...>"
links: local paths and UNC paths.
Local path URI
This is the path to a file accessible inside the client machine, either because the file is inside its local storage or because it is accessible through a mapped drive / mounted folder.
Those URI take 3 slashes:
file:///p:/share/path/to/file
file:////mnt/share/path/to/file
The fourth slash for the second example is the UNIX root /
.
UNC path URI
The format I show in my question, file://///server/share/path/to/file
, is known as an UNC path.
This is a path accessible from the client machine through an internal URI, like my.server.com
. In Windows, for example, this is when you use the server URI to access the file, not its mapped drive letter.
Those URI take 5 slashes:
file://///my.server.com/share/path/to/file
The links that helped me answer my question:
The "about" section of the Firefox Local Filesystem Links Extension also talks about it: