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.
Path/File. The path refers to the exact location of a page, post, file, or other asset. It is often analogous to the underlying file structure of the website. The path resides after the hostname and is separated by “/” (forward slash). The path/file also consists of any asset file extension, such as images (.
A valid file URI must therefore begin with either file:/path (no hostname), file:///path (empty hostname), or file://hostname/path . file://path (i.e. two slashes, without a hostname) is never correct, but is often used.
file is a registered URI scheme (for "Host-specific file names"). So yes, file URIs are URLs.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With