9

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.

1 Answer 1

14

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

3
  • Yes, I thought on that, but JavaScript's URL parser ignores the root directory. Do you think there are rules for file: protocol?
    – user5066707
    Commented Oct 16, 2016 at 13:25
  • 1
    this is just meant to be used by browsers to browse files only on the same system... do you ever used it at any other place.. other than browser... where it showed a successful result.. Commented Oct 16, 2016 at 13:30
  • I think I got it, the Wiki examples did the same action as in the JS's URL parser. Replying, if I used these URLs in elsewhere, this may have been a long time ago
    – user5066707
    Commented Oct 16, 2016 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.