Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

url

file-uri

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.

like image 999
Klaider Avatar asked Oct 16 '16 13:10

Klaider


People also ask

What is a file path URL?

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 (.

What does a file URL look like?

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.

Is file a valid URL?

file is a registered URI scheme (for "Host-specific file names"). So yes, file URIs are URLs.


1 Answers

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

like image 191
sanjeev Avatar answered Dec 03 '22 14:12

sanjeev