Examples of URI, URL and URN

前端 未结 2 1136
忘掉有多难
忘掉有多难 2020-12-10 20:04

I have read many articles about URIs, URLs and URNs, but I don\'t understand the diff in real examples.

Could you

2条回答
  •  没有蜡笔的小新
    2020-12-10 20:37

    No, the image is not correct. Your two examples are both, URIs and URLs.

    Every URL is a URI.
    Every URN is a URI.

    Background

    According to W3C’s URIs, URLs, and URNs: Clarifications and Recommendations 1.0 (also published by the IETF as RFC 3305):

    • In the classical view, a URI is a URL if it specifies the location of a resource, and a URI is a URN if it specifies the name of a resource.

    • In the contemporary view, making this differentiation is not relevant or useful.

    • Confusion may arise because the terms "URI" and "URL" are often used synonymously.

    Using one term for everything: URI or URL

    The Internet Standard for URIs, STD 66 (which currently maps to RFC 3986), recommends:

    Future specifications and related documentation should use the general term "URI" rather than the more restrictive terms "URL" and "URN"

    WHATWG’s URL Living Standard (and W3C’s version of it) says:

    Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone.

    My recommendation

    • Use "URL" and/or "URI" (or "IRI", if the difference is relevant) for everything.
    • Use "URN" only for URIs with the urn URI scheme, and only if you need to be specific.

提交回复
热议问题