Difference between a URI, a URL, and a URN?
💻 coding

Difference between a URI, a URL, and a URN?

1 min read 225 words
1 min read
ShareWhatsAppPost on X
  • 1A URI can be classified as a locator, a name, or both, encompassing URLs and URNs.
  • 2URLs are a subset of URIs that provide a means of locating a resource via its access mechanism.
  • 3URNs are unique and persistent identifiers that can refer to resources even if they become unavailable.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"A URI can be classified as a locator, a name, or both, encompassing URLs and URNs."

Difference between a URI, a URL, and a URN?

I have seen many people talk about URLs, URIs, and URNs as if they're different things, but they look the same to the naked eye.

What are the distinguishable differences between them?

From http://www.ietf.org/rfc/rfc3986.txt

A URI can be further classified as a locator, a name, or both. 
The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, 
in addition to identifying a resource, 
provide a means of locating the resource by 
describing its primary access mechanism (e.g., its network "location"). 
The term "Uniform Resource Name" (URN) has been used historically to refer 
to both URIs under the "urn" scheme [RFC2141], 
which are required to remain globally unique and persistent even when the 
resource ceases to exist or becomes unavailable, 
and to any other URI with the properties of a name.

So all URLs are URIs (actually not quite - see below), and all URNs are URIs - but URNs and URLs are different, so you can't say that all URIs are URLs.

EDIT: I had previously thought that all URLs are valid URIs, but as per comments:

Not "all URLs are URIs". It depends on the interpretation of the RFC. 
For example in Java the URI parser does not like [ or ] and that's 
because the spec says "should not" and not "shall not".

So that muddies the waters further, unfortunately.

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 28 November 2018 · 1 min read · 225 words

Part of AskGif Blog · coding

You might also like