Hacker News new | ask | show | jobs
by EamonnMR 2160 days ago
Whenever I see a person or API use URI instead of URL I feel like I'm in an alternate universe. Turns out the distinction is that URIs can include things like ISBN numbers, but everything with a protocol string is a URL so really URL is probably the right term for most modern uses.
2 comments

To be clear, the difference is that an URI generally only allows you to refer to a resource ("Identifier"), whereas an URL also tells you where to find and access it ("Locator").

For instance, `https://example.com/foo` tells you that the resource can be accessed via the HTTPS protocol, at the server with the hostname example.com (on port 443), by asking it for the path `/foo`. It is hence an URL. On the other hand, `isbn:123456789012` precisely identifies a specific book, but gives you no information about how to locate it. Thus, it is just an URI, not an URL. (Every URL is also an URI, though.)

A URI that cannot be used as a URL (ie as a locator for the resource) is a URN (a name).
I agree, but the confusion will continue. I read maybe a decade ago that URLs are just for network content and came away with the understanding that while URIs could include any "protocol" (like file: or smb: or about:) URLs were more specific. And thus if you wanted to talk about protocol agnostic locations, you should use URI. But that was totally wrong!!

End of the day, there is not clarity, so just use the term that will be best understood by the person you are talking to. URL is a good default, probably even for "about:"