Letseatlunch
Letseatlunch

Reputation: 2487

What is the difference between file://<somewhere> and file:///<somewhere>?

What is the difference between file://<somewhere> and file:///<somewhere>?

Upvotes: 2

Views: 123

Answers (1)

cHao
cHao

Reputation: 86506

file:///some/path is equivalent to file://localhost/some/path, and refers to a file named /some/path on the local machine, whereas file://some/path refers to a file named path on a machine named some.

See RFC 1738, section 3.10:

3.10 FILES

The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet.

A file URL takes the form:

  file://<host>/<path>

where <host> is the fully qualified domain name of the system on which the <path> is accessible, and <path> is a hierarchical directory path of the form <directory>/<directory>/.../<name>.

For example, a VMS file

   DISK$USER:[MY.NOTES]NOTE123456.TXT

might become

   <URL:file://vms.host.edu/disk$user/my/notes/note12345.txt>

As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as `the machine from which the URL is being interpreted'.

file://<path> happens to work a lot of the time when you try to use it as a URL, because the error is common enough that many programs just assume it's going to happen. But it's ambiguous at best, and downright wrong at worst.

Upvotes: 3

Related Questions