Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a "file://" path a URL?

Tags:

url

path

uri

I sometimes see people refer to file system paths (POSIX/Windows) as both URIs and URLs. I'm no file system buff, but I have yet to find a file system path that conflicts with my understanding of the URL format. That is, of course, given that it includes the scheme name (e.g. file://localhost/path/to/file.txt).

File system paths are most definitely URIs - I mean, what's not - so everyone referring to file system paths as URIs is inside the safe zone. But is it safe to call them URLs?

If the URL was defined by a single (non-obsolete) RFC, rather than being comprised of half a dozen specialized ones, I wouldn't have to ask this question.

like image 783
Johan Fredrik Varen Avatar asked Dec 13 '12 22:12

Johan Fredrik Varen


People also ask

Is path the same as URL?

URL includes the protocol being used (http:// etc). Path doesn't or doesn't need at least. Also, URLs can percent-encode characters like spaces.

How do I convert a file path to URL?

Solution 1. There is no way to convert it, unless you are going to buy a hosting and domain using your desired domain name.

What do you mean by a file path?

A file path describes the location of a file in a web site's folder structure. File paths are used when linking to external files, like: Web pages. Images. Style sheets.

Can a file be a URL?

A URL file is a shortcut that points to a specific Uniform Resource Locator. When you double-click a URL file, your computer accesses the URL the file contains. URL files most often contain https: web addresses and are used to access web pages. However, URL files can also contain mailto:, tel:, file:, or other URLs.


1 Answers

file is a registered URI scheme (for "Host-specific file names").

It links to RFC 1738, which is called "Uniform Resource Locators (URL)", in which file is specified:

A file URL takes the form:

file://<host>/<path>

So yes, file URIs are URLs.

However, the subdivision from URIs into URLs, URNs and "Other" (like data) is not that useful anyway. FWIW, the WHATWG URL spec tries to standardize on the term "URL" for all kind of URIs (even those that aren't URLs today, following the RFC). The W3C Note "URIs, URLs, and URNs: Clarifications and Recommendations 1.0" tries to summarize the confusion about the terms:

The body of documents (RFCs, etc) covering URI architecture, syntax, registration, etc., spans both the classical and contemporary periods. People who are well-versed in URI matters tend to use "URL" and "URI" in ways that seem to be interchangable. Among these experts, this isn't a problem. But among the Internet community at large, it is. People are not convinced that URI and URL mean the same thing, in documents where they (apparently) do. […]

like image 158
unor Avatar answered Nov 18 '22 00:11

unor