From 24328860e6aa143df3f5cb0a82d3dae235ee21f8 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Mon, 16 Jan 2023 17:59:53 +0000 Subject: [PATCH 01/33] Added web.dev/url --- src/site/content/en/blog/url/index.md | 281 ++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 src/site/content/en/blog/url/index.md diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md new file mode 100644 index 00000000000..efd9cf03b3b --- /dev/null +++ b/src/site/content/en/blog/url/index.md @@ -0,0 +1,281 @@ +--- +title: What are the parts of a URL? +subhead: "What's the difference between a domain name, hostname, site and origin? This article explains." +authors: + - samdutton +date: 2023-01-19 +hero: image/80mq7dk16vVEg8BBhsVe42n6zn82/CVV3xEIQFGopaQCq0JJW.png +alt: +tags: + - blog + - html + - network + - privacy +--- + +Most of the time it's fine to be relaxed about naming when talking about websites and URLs. It's +usually OK to say things like "I bought a domain name"' or "Our images are hosted on a different +site"—even if that's not strictly true. + +However, in some contexts it's crucial to be accurate and specific when referring to the parts of a +URL. For example, when dealing with cookies, you need to understand the difference between +[site](#site) +and +[origin](#origin). + This article is designed to help with that. + +The examples here are only intended as a guide. [The URL Living +Standard](https://url.spec.whatwg.org/) provides formal definitions of URL parts. + +{% Aside 'caution' %} +The named parts of a URL may coincide, but that doesn't mean they're equivalent! + +In the first example below, the FQDN, eTLD+1, hostname, site and registrable domain are all the +same, but each term has a different meaning. +{% endAside %} + +## Examples + +{% Img src="image/80mq7dk16vVEg8BBhsVe42n6zn82/CVV3xEIQFGopaQCq0JJW.png", alt="ALT_TEXT_HERE", width="800", height="177" %} + +{% Img src="image/80mq7dk16vVEg8BBhsVe42n6zn82/oqP4zn3qBkZChbjNaVCQ.png", alt="ALT_TEXT_HERE", width="800", height="177" %} + +## Glossary + +**Anchor** {: #anchor} + +See +[hash](#hash). + +**Country-code top-level domain** (ccTLD) {: #cctld} + +A +[top-level domain](#tld) +defined in the [ISO 3166-1 Country Codes +list](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes). + +- For `https://example.com.au`, the ccTLD is `au`. + +**Domain name ** {: #domain-name} + +The parts of a URL separated by dots: everything after the [scheme](#scheme), but before the +[path](#pathname) or [port](#port) (if specified). + +- For `https://example.github.io/path`, the domain name is `example.github.io`. +- For `https://support.example.com.au:443`, the domain name is `support.example.com.au`. +- Each part of the domain name is known as a + [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en). + +**Effective top-level domain** (eTLD) {: #etld} + +An entry in the [Public Suffix List](https://publicsuffix.org/list/), including a +[TLD](#tld) and +a +[second-level domain](#sld). + +- For example: `github.io`, `com.au`. + +**eTLD+1** {: #etld1} + +An [eTLD](#etld) +plus the subdomain that precedes it. + +- For example: `example.github.io`, `example.com.au`. + +**Fully-qualified domain name** (FQDN) {: #fqdn} + +A complete address for a website or a server, that maps to an [IP address](https://en.wikipedia.org/wiki/IP_address). + +- For `https://example.com:443/cats` the FQDN is `example.com`. +- For `https://api.example.github.io`, the FQDN is `api.example.github.io`. + +{% Aside %} +The FQDN for a URL does not include the [port](#port), even if the port is provided in the URL. +{% endAside %} + +**Hash** {: #hash} + +Also known as "anchor". + +A string following a `#` character at the end of a URL that provides a +[fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). +For example, the URL `https://example.com/cats#tabby` has the hash value (anchor) `tabby`. + +URL spec: [hash](https://url.spec.whatwg.org/#dom-url-hash) +URL API: [hash](https://developer.mozilla.org/docs/Web/API/URL/hash) + +{% Aside %} +The hash value is not passed when an HTTP request is made to a server. +{% endAside %} + +**Host** {: #host} + +The [domain name](#domain-name), followed by the port if defined. + +- For `https://www.example.com:443/foo`, the host is `www.example.com:443`. +- For `https://support.example.github.io`, the host is `support.example.github.io`. + +URL spec: [host](https://url.spec.whatwg.org/#dom-url-host) +URL API: [host](https://developer.mozilla.org/docs/Web/API/URL/host) + +**Hostname** {: #hostname} + +Generally equivalent to [domain name](#domain-name), but see +[Host representation](https://url.spec.whatwg.org/#concept-domain) in the WHATWG URL standard for +more detail. + +URL spec: [hostname](https://url.spec.whatwg.org/#dom-url-hostname) +URL API: [hostname](https://developer.mozilla.org/docs/Web/API/URL/hostname) + +{% Aside %} +Unlike [host](#host), the hostname of a URL does not include the [port](#port). +{% endAside %} + +**Origin** {: #origin} + +The [scheme](#scheme) followed by the [host](#host). + +- For `https://www.example.com:443/foo`, the origin is `https://www.example.com:443`. +- For `https://support.example.github.io`, the origin is `https://support.example.github.io:443`. + +URL spec: [origin](https://url.spec.whatwg.org/#dom-url-origin) +URL API: [origin](https://developer.mozilla.org/docs/Web/API/URL/origin) + +{% Aside %} +Unlike [site](#site), origin includes the [scheme](#scheme) and [port](#port) (if provided in the +URL). +{% endAside %} + +**Parameter** {: #parameter} + +An item of data passed in a [query string](#query-string). + +- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the query string has two + parameters: `pattern=tabby` and `mood=bonkers`. + +URL spec: [searchParams](https://url.spec.whatwg.org/#dom-url-searchparams) +URL API: [searchParams](https://developer.mozilla.org/docs/Web/API/URL/searchParams) + +**Pathname** {: #pathname} + +The part of a URL after the domain and port (if defined), including a filename (if defined) but not +including the [query string](#query-string) or [hash](#hash). + +- For `https://example.com:8000/search?q=tabby`, the pathname is `/search`. +- For `example.github.io/foo`, the pathname is `/foo`. +- For `example.github.io/README.md`, the pathname is `/README.md`. +- For `example.com`, the pathname is an empty string. + +The 'path' component of a URL is sometimes used to refer to the pathname without the filename. + +URL spec: [pathname](https://url.spec.whatwg.org/#dom-url-pathname) +URL API: [pathname](https://developer.mozilla.org/docs/Web/API/URL/pathname) + +**Port** {: #port} + +A string following a `:` in a URL providing an integer that identifies a network port. For example, +in the URL `https://example.com:443/tabby`, the port number is 443. + +URL spec: [port](https://url.spec.whatwg.org/#dom-url-port) +URL API: [port](https://developer.mozilla.org/docs/Web/API/URL/port) + +**Query string** {: #query-string} + +Also known as search string. + +A series of key/value pairs that represent [parameters](#parameter), at the end of a URL after a +question mark. + +- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the query string is + `pattern=tabby&mood=bonkers`. + +URL spec: [search](https://url.spec.whatwg.org/#dom-url-search) +URL API: [search](https://developer.mozilla.org/docs/Web/API/URL/search) + +**Registrable domain** {: #registrable-domain} + +- For a site with a single-part top-level domain such as `com` or `org`, the top-level domain + and the [second-level domain](#sld) before it: for example, `example.com` or `example.org`. +- For a top-level domain where only third-level registration is allowed (i.e. entries in the + [Public Suffix List](https://publicsuffix.org/list/) such as `co.uk` and, `github.io`) the + two-part top-level domain ('public suffix') and the third-level domain name just before that: + for example, `example.co.uk` or `example.com.au`. (Confusingly, perhaps, domains such as + `example.github.io` or `example.glitch.me` are [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though they cannot be registered via a domain name registrar.) + +**Scheme** {: #scheme} + +The part of the URL (before `://`) that defines the [protocol](https://developer.mozilla.org/docs/Glossary/Protocol) +(or action to be taken by the user agent) when a request is made to a URL. For example, a request +to a URL with an `https` scheme should be made using the [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS). +For a request to a URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a +network protocol, the behaviour depends on the user agent. For example, when a user clicks on a +`mailto` link, the browser might open its default email application, using the values in the link +URL. + +URL API: [protocol](https://developer.mozilla.org/docs/Web/API/URL/protocol) +URL spec: [protocol](https://url.spec.whatwg.org/#dom-url-protocol) + +**Second-level domain** {: #sld} + +The domain before the [top-level domain](#tld): + +- For the URL `https://www.example.com`, `example.com` is the second-level domain, a + [subdomain](#subdomain) of the top-level domain `com`. +- For `https://example.com.au`, the top-level domain is `au`, the second-level domain is `com` + and the third-level domain is `example`. In this example, `com.au` is a subdomain of `au` and + `example.com.au` is a subdomain of `com.au`. + +**Site** {: #site} + +- For a site such as `example.com` with a single-part top-level domain: the top-level domain + and the part before it. For example, for the URL `https://www.example.com/foo`, the site is + `example.com`. +- For an [eTLD](#tld) + where only third-level registrations are allowed (such as `co.uk` or `github.io`) the top-level + domain ('public suffix') and the part of the domain name just before that. For example, for the + URL `https://www.example.co.uk/foo`, the site is `example.co.uk`. (Confusingly, perhaps, + domains such as `example.github.io` or `example.glitch.me` are also + [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though + they cannot be registered via a domain name registrar.) + +{% Aside %} +Unlike [origin](#origin), site does not include the [scheme](#scheme) or [port](#port). +{% endAside %} + +**Subdomain**{: #subdomain} + +A domain within a higher-level domain. + +For sites with single-part top-level domains such as `.com` or `.org`, the parts before the +top-level domain, each of which is separated by a dot. +- `www.example.com` is a subdomain of `example.com`. +- `support.api.example.org` is a subdomain of `api.example.org`, which is a subdomain + of `example.org`. + +For top-level domains where only third-level registrations are allowed (i.e. entries in the +[Public Suffix List](https://publicsuffix.org/list/) such as co.uk and github.io) the parts of +the domain name before that. +- For example, `support.example.co.uk`, is a subdomain of `example.co.uk`. + +**Top-level domain** (TLD) {: #tld} + +- A domain name listed in the [Root Zone Database](https://www.iana.org/domains/root/db) such + as `com`, `io` or `org`. +- Some top-level domains are [country code top-level domains](#cctld), such as +`[uk](https://www.iana.org/domains/root/db/uk.html)` and `[tv](https://www.iana.org/domains/root/db/tv.html)`. +- When describing the parts of a URL, the domain name that follows the final dot. + - For `https://example.com`, the URL's top-level domain is `com`. + - For `https://example.com.au`, the URL's top-level domain is `au`, and `com` is a + [second-level domain](#sld) (even though `com` is also a potential top-level domain!) + +## Find out more + +- [WHATWG: URL Living Standard](https://url.spec.whatwg.org/) +- [URL API](https://developer.mozilla.org/docs/Web/API/URL_API) +- [RFC: Uniform Resource Locators (URL)](https://www.rfc-editor.org/rfc/rfc1738) +- [RFC: URIs, URLs and URNs](https://datatracker.ietf.org/doc/html/rfc3305) +- [Root Zone Database](https://www.iana.org/domains/root/db) (directory of [TLDs](#tld)) +- [Public Suffix List](https://publicsuffix.org/list/) (directory of [eTLDs](#etld)) +- [ICANN glossary](https://www.icann.org/en/icann-acronyms-and-terms?nav-letter=r&page=1) +- [What is a Fully Qualified Domain Name?](https://datatracker.ietf.org/doc/html/rfc1594#section-5) +- [How many ways can you slice a URL and name the pieces?](https://tantek.com/2011/238/b1/many-ways-slice-url-name-pieces) \ No newline at end of file From 84f697b2c97af6eff73da191e920fc82d2525f2f Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 17 Feb 2023 17:55:30 +0000 Subject: [PATCH 02/33] Updates --- src/site/content/en/blog/url/index.md | 143 +++++++++++++------------- 1 file changed, 74 insertions(+), 69 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index efd9cf03b3b..065cb62120e 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -4,7 +4,7 @@ subhead: "What's the difference between a domain name, hostname, site and origin authors: - samdutton date: 2023-01-19 -hero: image/80mq7dk16vVEg8BBhsVe42n6zn82/CVV3xEIQFGopaQCq0JJW.png +hero: image/80mq7dk16vVEg8BBhsVe42n6zn82/EAQ6QLeBBonbpyqeGWPb.jpg alt: tags: - blog @@ -15,48 +15,52 @@ tags: Most of the time it's fine to be relaxed about naming when talking about websites and URLs. It's usually OK to say things like "I bought a domain name"' or "Our images are hosted on a different -site"—even if that's not strictly true. +site", even if that's not strictly true. -However, in some contexts it's crucial to be accurate and specific when referring to the parts of a +In some contexts, however, it's crucial to be accurate and specific when referring to the parts of a URL. For example, when dealing with cookies, you need to understand the difference between [site](#site) and [origin](#origin). This article is designed to help with that. -The examples here are only intended as a guide. [The URL Living +The examples and explanations here are intended as a guide: [The URL Living Standard](https://url.spec.whatwg.org/) provides formal definitions of URL parts. -{% Aside 'caution' %} +{% Aside %} The named parts of a URL may coincide, but that doesn't mean they're equivalent! - + In the first example below, the FQDN, eTLD+1, hostname, site and registrable domain are all the same, but each term has a different meaning. {% endAside %} ## Examples -{% Img src="image/80mq7dk16vVEg8BBhsVe42n6zn82/CVV3xEIQFGopaQCq0JJW.png", alt="ALT_TEXT_HERE", width="800", height="177" %} +{% Img src="image/80mq7dk16vVEg8BBhsVe42n6zn82/CVV3xEIQFGopaQCq0JJW.png", + alt="Sample URL with parts labeled.", width="800", height="177" %} + +--- + +{% Img src="image/80mq7dk16vVEg8BBhsVe42n6zn82/2NzKEa4kGfn6pi3w4oLd.png", + alt="Sample URL with parts labeled.", width="800", height="177" %} -{% Img src="image/80mq7dk16vVEg8BBhsVe42n6zn82/oqP4zn3qBkZChbjNaVCQ.png", alt="ALT_TEXT_HERE", width="800", height="177" %} +--- ## Glossary -**Anchor** {: #anchor} +### Anchor {: #anchor} See [hash](#hash). -**Country-code top-level domain** (ccTLD) {: #cctld} +### Country-code top-level domain (ccTLD) {: #cctld} -A -[top-level domain](#tld) -defined in the [ISO 3166-1 Country Codes -list](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes). +A [top-level domain](#tld) defined in the +[ISO 3166-1 Country Codes list](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes). - For `https://example.com.au`, the ccTLD is `au`. -**Domain name ** {: #domain-name} +### Domain name {: #domain-name} The parts of a URL separated by dots: everything after the [scheme](#scheme), but before the [path](#pathname) or [port](#port) (if specified). @@ -66,97 +70,91 @@ The parts of a URL separated by dots: everything after the [scheme](#scheme), bu - Each part of the domain name is known as a [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en). -**Effective top-level domain** (eTLD) {: #etld} +### Effective top-level domain (eTLD) {: #etld} An entry in the [Public Suffix List](https://publicsuffix.org/list/), including a -[TLD](#tld) and -a -[second-level domain](#sld). +[TLD](#tld) and a [second-level domain](#sld). - For example: `github.io`, `com.au`. -**eTLD+1** {: #etld1} +### eTLD+1 {: #etld1} An [eTLD](#etld) plus the subdomain that precedes it. - For example: `example.github.io`, `example.com.au`. -**Fully-qualified domain name** (FQDN) {: #fqdn} +### Fully-qualified domain name (FQDN) {: #fqdn} A complete address for a website or a server, that maps to an [IP address](https://en.wikipedia.org/wiki/IP_address). - For `https://example.com:443/cats` the FQDN is `example.com`. - For `https://api.example.github.io`, the FQDN is `api.example.github.io`. -{% Aside %} +{% Aside %} The FQDN for a URL does not include the [port](#port), even if the port is provided in the URL. {% endAside %} -**Hash** {: #hash} +### Hash {: #hash} Also known as "anchor". A string following a `#` character at the end of a URL that provides a [fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). + For example, the URL `https://example.com/cats#tabby` has the hash value (anchor) `tabby`. -URL spec: [hash](https://url.spec.whatwg.org/#dom-url-hash) -URL API: [hash](https://developer.mozilla.org/docs/Web/API/URL/hash) +[Spec](https://url.spec.whatwg.org/#dom-url-hash) • [API](https://developer.mozilla.org/docs/Web/API/URL/hash) -{% Aside %} +{% Aside 'important' %} The hash value is not passed when an HTTP request is made to a server. {% endAside %} -**Host** {: #host} +### Host {: #host} The [domain name](#domain-name), followed by the port if defined. - For `https://www.example.com:443/foo`, the host is `www.example.com:443`. - For `https://support.example.github.io`, the host is `support.example.github.io`. -URL spec: [host](https://url.spec.whatwg.org/#dom-url-host) -URL API: [host](https://developer.mozilla.org/docs/Web/API/URL/host) +[Spec](https://url.spec.whatwg.org/#dom-url-host) • [API](https://developer.mozilla.org/docs/Web/API/URL/host) -**Hostname** {: #hostname} +### Hostname {: #hostname} Generally equivalent to [domain name](#domain-name), but see [Host representation](https://url.spec.whatwg.org/#concept-domain) in the WHATWG URL standard for more detail. -URL spec: [hostname](https://url.spec.whatwg.org/#dom-url-hostname) -URL API: [hostname](https://developer.mozilla.org/docs/Web/API/URL/hostname) +[Spec](https://url.spec.whatwg.org/#dom-url-hostname) • [API](https://developer.mozilla.org/docs/Web/API/URL/hostname) -{% Aside %} +{% Aside %} Unlike [host](#host), the hostname of a URL does not include the [port](#port). {% endAside %} -**Origin** {: #origin} +### Origin {: #origin} The [scheme](#scheme) followed by the [host](#host). - For `https://www.example.com:443/foo`, the origin is `https://www.example.com:443`. - For `https://support.example.github.io`, the origin is `https://support.example.github.io:443`. -URL spec: [origin](https://url.spec.whatwg.org/#dom-url-origin) -URL API: [origin](https://developer.mozilla.org/docs/Web/API/URL/origin) +[Spec](https://url.spec.whatwg.org/#dom-url-origin) • [API](https://developer.mozilla.org/docs/Web/API/URL/origin) -{% Aside %} -Unlike [site](#site), origin includes the [scheme](#scheme) and [port](#port) (if provided in the -URL). +{% Aside %} +Unlike [site](#site), origin includes the [scheme](#scheme) and [port](#port) +(if provided in the URL). {% endAside %} -**Parameter** {: #parameter} +### Parameter {: #parameter} An item of data passed in a [query string](#query-string). - For `https://example.com/cats?pattern=tabby&mood=bonkers`, the query string has two parameters: `pattern=tabby` and `mood=bonkers`. -URL spec: [searchParams](https://url.spec.whatwg.org/#dom-url-searchparams) -URL API: [searchParams](https://developer.mozilla.org/docs/Web/API/URL/searchParams) +[Spec](https://url.spec.whatwg.org/#dom-url-searchparams) • [API](https://developer.mozilla.org/docs/Web/API/URL/searchParams) -**Pathname** {: #pathname} +### Pathname {: #pathname} The part of a URL after the domain and port (if defined), including a filename (if defined) but not including the [query string](#query-string) or [hash](#hash). @@ -168,18 +166,16 @@ including the [query string](#query-string) or [hash](#hash). The 'path' component of a URL is sometimes used to refer to the pathname without the filename. -URL spec: [pathname](https://url.spec.whatwg.org/#dom-url-pathname) -URL API: [pathname](https://developer.mozilla.org/docs/Web/API/URL/pathname) +[Spec](https://url.spec.whatwg.org/#dom-url-pathname) • [API](https://developer.mozilla.org/docs/Web/API/URL/pathname) -**Port** {: #port} +### Port {: #port} A string following a `:` in a URL providing an integer that identifies a network port. For example, in the URL `https://example.com:443/tabby`, the port number is 443. -URL spec: [port](https://url.spec.whatwg.org/#dom-url-port) -URL API: [port](https://developer.mozilla.org/docs/Web/API/URL/port) +[Spec](https://url.spec.whatwg.org/#dom-url-port) • [API](https://developer.mozilla.org/docs/Web/API/URL/port) -**Query string** {: #query-string} +### Query string {: #query-string} Also known as search string. @@ -189,20 +185,24 @@ question mark. - For `https://example.com/cats?pattern=tabby&mood=bonkers`, the query string is `pattern=tabby&mood=bonkers`. -URL spec: [search](https://url.spec.whatwg.org/#dom-url-search) -URL API: [search](https://developer.mozilla.org/docs/Web/API/URL/search) +[Spec](https://url.spec.whatwg.org/#dom-url-search) • [API](https://developer.mozilla.org/docs/Web/API/URL/search) -**Registrable domain** {: #registrable-domain} +### Registrable domain {: #registrable-domain} - For a site with a single-part top-level domain such as `com` or `org`, the top-level domain and the [second-level domain](#sld) before it: for example, `example.com` or `example.org`. - For a top-level domain where only third-level registration is allowed (i.e. entries in the [Public Suffix List](https://publicsuffix.org/list/) such as `co.uk` and, `github.io`) the two-part top-level domain ('public suffix') and the third-level domain name just before that: - for example, `example.co.uk` or `example.com.au`. (Confusingly, perhaps, domains such as - `example.github.io` or `example.glitch.me` are [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though they cannot be registered via a domain name registrar.) + for example, `example.co.uk` or `example.com.au`. -**Scheme** {: #scheme} +{% Aside %} +Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` +are [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) +though they cannot be registered via a domain name registrar. +{% endAside %} + +### Scheme {: #scheme} The part of the URL (before `://`) that defines the [protocol](https://developer.mozilla.org/docs/Glossary/Protocol) (or action to be taken by the user agent) when a request is made to a URL. For example, a request @@ -212,10 +212,9 @@ network protocol, the behaviour depends on the user agent. For example, when a u `mailto` link, the browser might open its default email application, using the values in the link URL. -URL API: [protocol](https://developer.mozilla.org/docs/Web/API/URL/protocol) -URL spec: [protocol](https://url.spec.whatwg.org/#dom-url-protocol) +[Spec](https://url.spec.whatwg.org/#dom-url-protocol) • [API](https://developer.mozilla.org/docs/Web/API/URL/protocol) -**Second-level domain** {: #sld} +### Second-level domain {: #sld} The domain before the [top-level domain](#tld): @@ -225,7 +224,7 @@ The domain before the [top-level domain](#tld): and the third-level domain is `example`. In this example, `com.au` is a subdomain of `au` and `example.com.au` is a subdomain of `com.au`. -**Site** {: #site} +### Site {: #site} - For a site such as `example.com` with a single-part top-level domain: the top-level domain and the part before it. For example, for the URL `https://www.example.com/foo`, the site is @@ -238,11 +237,11 @@ The domain before the [top-level domain](#tld): [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though they cannot be registered via a domain name registrar.) -{% Aside %} +{% Aside %} Unlike [origin](#origin), site does not include the [scheme](#scheme) or [port](#port). {% endAside %} -**Subdomain**{: #subdomain} +### Subdomain {: #subdomain} A domain within a higher-level domain. @@ -255,18 +254,20 @@ top-level domain, each of which is separated by a dot. For top-level domains where only third-level registrations are allowed (i.e. entries in the [Public Suffix List](https://publicsuffix.org/list/) such as co.uk and github.io) the parts of the domain name before that. -- For example, `support.example.co.uk`, is a subdomain of `example.co.uk`. +- For example, `support.example.co.uk` is a subdomain of `example.co.uk`. -**Top-level domain** (TLD) {: #tld} +### Top-level domain (TLD) {: #tld} - A domain name listed in the [Root Zone Database](https://www.iana.org/domains/root/db) such as `com`, `io` or `org`. - Some top-level domains are [country code top-level domains](#cctld), such as -`[uk](https://www.iana.org/domains/root/db/uk.html)` and `[tv](https://www.iana.org/domains/root/db/tv.html)`. -- When describing the parts of a URL, the domain name that follows the final dot. - - For `https://example.com`, the URL's top-level domain is `com`. - - For `https://example.com.au`, the URL's top-level domain is `au`, and `com` is a - [second-level domain](#sld) (even though `com` is also a potential top-level domain!) +[`uk`](https://www.iana.org/domains/root/db/uk.html) and +[`tv`](https://www.iana.org/domains/root/db/tv.html). + +When describing the parts of a URL, the domain name that follows the final dot. +- For `https://example.com`, the URL's top-level domain is `com`. +- For `https://example.com.au`, the URL's top-level domain is `au`, and `com` is a +[second-level domain](#sld) (even though `com` is also a potential top-level domain!) ## Find out more @@ -278,4 +279,8 @@ the domain name before that. - [Public Suffix List](https://publicsuffix.org/list/) (directory of [eTLDs](#etld)) - [ICANN glossary](https://www.icann.org/en/icann-acronyms-and-terms?nav-letter=r&page=1) - [What is a Fully Qualified Domain Name?](https://datatracker.ietf.org/doc/html/rfc1594#section-5) -- [How many ways can you slice a URL and name the pieces?](https://tantek.com/2011/238/b1/many-ways-slice-url-name-pieces) \ No newline at end of file +- [How many ways can you slice a URL and name the pieces?](https://tantek.com/2011/238/b1/many-ways-slice-url-name-pieces) + + + +Photo by [Mathyas Kurmann](https://unsplash.com/@mathyaskurmann) on [Unsplash](https://unsplash.com/photos/fb7yNPbT0l8). From c7943170c2e5a021abb50df84b6dfb585cc630ad Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 17 Feb 2023 19:00:36 +0000 Subject: [PATCH 03/33] Updated for site --- src/site/content/en/blog/url/index.md | 96 ++++++++++++++++----------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 065cb62120e..2cf86c44181 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -3,7 +3,7 @@ title: What are the parts of a URL? subhead: "What's the difference between a domain name, hostname, site and origin? This article explains." authors: - samdutton -date: 2023-01-19 +date: 2023-02-20 hero: image/80mq7dk16vVEg8BBhsVe42n6zn82/EAQ6QLeBBonbpyqeGWPb.jpg alt: tags: @@ -14,27 +14,33 @@ tags: --- Most of the time it's fine to be relaxed about naming when talking about websites and URLs. It's -usually OK to say things like "I bought a domain name"' or "Our images are hosted on a different +usually OK to say things like "I bought a domain name" or "Our images are hosted on a different site", even if that's not strictly true. -In some contexts, however, it's crucial to be accurate and specific when referring to the parts of a +However, in some contexts it's crucial to be accurate and specific when referring to the parts of a URL. For example, when dealing with cookies, you need to understand the difference between -[site](#site) -and -[origin](#origin). - This article is designed to help with that. +[site](#site) and [origin](#origin). This article is designed to help with that. -The examples and explanations here are intended as a guide: [The URL Living -Standard](https://url.spec.whatwg.org/) provides formal definitions of URL parts. +The explanations here are only intended as a guide: +[The URL Living Standard](https://url.spec.whatwg.org/) provides formal definitions of URL parts. {% Aside %} The named parts of a URL may coincide, but that doesn't mean they're equivalent! -In the first example below, the FQDN, eTLD+1, hostname, site and registrable domain are all the -same, but each term has a different meaning. -{% endAside %} +The [FQDN](#fqdn), [eTLD+1](#etld1), [hostname](#hostname) and [registrable domain](#registrable-domain) +may be the same for some URLs, but each term has a different meaning. +{% endAside %} + +Edit the URL in the Glitch below to see the part names. (You can also open this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me).) + +{% Glitch 'url-parts' %} + -## Examples + + + ## Glossary @@ -141,15 +147,14 @@ The [scheme](#scheme) followed by the [host](#host). [Spec](https://url.spec.whatwg.org/#dom-url-origin) • [API](https://developer.mozilla.org/docs/Web/API/URL/origin) {% Aside %} -Unlike [site](#site), origin includes the [scheme](#scheme) and [port](#port) -(if provided in the URL). +Unlike [site](#site), origin includes the [port](#port) if provided in the URL. {% endAside %} ### Parameter {: #parameter} -An item of data passed in a [query string](#query-string). +An item of data passed in a [search string](#search) (also known as a 'query string'). -- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the query string has two +- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the search string has two parameters: `pattern=tabby` and `mood=bonkers`. [Spec](https://url.spec.whatwg.org/#dom-url-searchparams) • [API](https://developer.mozilla.org/docs/Web/API/URL/searchParams) @@ -157,7 +162,7 @@ An item of data passed in a [query string](#query-string). ### Pathname {: #pathname} The part of a URL after the domain and port (if defined), including a filename (if defined) but not -including the [query string](#query-string) or [hash](#hash). +including the [search string](#search) or [hash](#hash). - For `https://example.com:8000/search?q=tabby`, the pathname is `/search`. - For `example.github.io/foo`, the pathname is `/foo`. @@ -175,17 +180,9 @@ in the URL `https://example.com:443/tabby`, the port number is 443. [Spec](https://url.spec.whatwg.org/#dom-url-port) • [API](https://developer.mozilla.org/docs/Web/API/URL/port) -### Query string {: #query-string} - -Also known as search string. +### Query string -A series of key/value pairs that represent [parameters](#parameter), at the end of a URL after a -question mark. - -- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the query string is - `pattern=tabby&mood=bonkers`. - -[Spec](https://url.spec.whatwg.org/#dom-url-search) • [API](https://developer.mozilla.org/docs/Web/API/URL/search) +See [search](#search). ### Registrable domain {: #registrable-domain} @@ -214,6 +211,20 @@ URL. [Spec](https://url.spec.whatwg.org/#dom-url-protocol) • [API](https://developer.mozilla.org/docs/Web/API/URL/protocol) +### Search {: #search} + +Also known as 'query string'. + +A series of key/value pairs that represent [parameters](#parameter), at the end of a URL after a +question mark. + +- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the search string is + `pattern=tabby&mood=bonkers`. + +[Spec](https://url.spec.whatwg.org/#dom-url-search) • [API](https://developer.mozilla.org/docs/Web/API/URL/search) + + + ### Second-level domain {: #sld} The domain before the [top-level domain](#tld): @@ -226,19 +237,23 @@ The domain before the [top-level domain](#tld): ### Site {: #site} -- For a site such as `example.com` with a single-part top-level domain: the top-level domain - and the part before it. For example, for the URL `https://www.example.com/foo`, the site is - `example.com`. -- For an [eTLD](#tld) - where only third-level registrations are allowed (such as `co.uk` or `github.io`) the top-level - domain ('public suffix') and the part of the domain name just before that. For example, for the - URL `https://www.example.co.uk/foo`, the site is `example.co.uk`. (Confusingly, perhaps, - domains such as `example.github.io` or `example.glitch.me` are also - [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though - they cannot be registered via a domain name registrar.) +{% Aside %} +According to the [URL Standard](https://url.spec.whatwg.org/), site includes [scheme](#scheme). +(See [discussion of 'same site'](https://github.com/whatwg/url/issues/448).) +{% endAside %} + +- For a site such as `https://example.com` with a single-part top-level domain: the scheme, plus + the top-level domain and the part before that. For example, for the URL + `https://www.example.com/foo`, the site is `https://example.com`. +- For an [eTLD](#tld) where only third-level registrations are allowed (such as `co.uk` or + `github.io`): the scheme, the top-level domain ('public suffix') and the part of the domain name + just before that. For example, for the URL `https://www.example.co.uk/foo`, the site is + `example.co.uk`. (Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` + are also [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) + though they cannot be registered via a domain name registrar.) {% Aside %} -Unlike [origin](#origin), site does not include the [scheme](#scheme) or [port](#port). +Unlike [origin](#origin), site does not include [port](#port). {% endAside %} ### Subdomain {: #subdomain} @@ -273,6 +288,7 @@ When describing the parts of a URL, the domain name that follows the final dot. - [WHATWG: URL Living Standard](https://url.spec.whatwg.org/) - [URL API](https://developer.mozilla.org/docs/Web/API/URL_API) +- [Understanding "same-site" and "same-origin"](/same-site-same-origin/) - [RFC: Uniform Resource Locators (URL)](https://www.rfc-editor.org/rfc/rfc1738) - [RFC: URIs, URLs and URNs](https://datatracker.ietf.org/doc/html/rfc3305) - [Root Zone Database](https://www.iana.org/domains/root/db) (directory of [TLDs](#tld)) From b76bce9b4b4e21abd039003236017571476576ad Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 13:17:18 +0000 Subject: [PATCH 04/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Alexandra White --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 2cf86c44181..0999baf28b0 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -13,7 +13,7 @@ tags: - privacy --- -Most of the time it's fine to be relaxed about naming when talking about websites and URLs. It's +Most of the time it's fine to be relaxed about naming websites and URLs. It's usually OK to say things like "I bought a domain name" or "Our images are hosted on a different site", even if that's not strictly true. From abe8bf729e200ef237861383a1ea75cb4d5921e7 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 13:17:27 +0000 Subject: [PATCH 05/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Alexandra White --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 0999baf28b0..539516f704d 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -15,7 +15,7 @@ tags: Most of the time it's fine to be relaxed about naming websites and URLs. It's usually OK to say things like "I bought a domain name" or "Our images are hosted on a different -site", even if that's not strictly true. +site," even if that's not strictly true. However, in some contexts it's crucial to be accurate and specific when referring to the parts of a URL. For example, when dealing with cookies, you need to understand the difference between From 4c6b5929be7d9898c5e2db48bf14a9723f06f4ee Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 13:21:11 +0000 Subject: [PATCH 06/33] Removed heading for 'anchor' --- src/site/content/en/blog/url/index.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 539516f704d..dedeb2e6342 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -3,7 +3,7 @@ title: What are the parts of a URL? subhead: "What's the difference between a domain name, hostname, site and origin? This article explains." authors: - samdutton -date: 2023-02-20 +date: 2023-02-22 hero: image/80mq7dk16vVEg8BBhsVe42n6zn82/EAQ6QLeBBonbpyqeGWPb.jpg alt: tags: @@ -54,11 +54,6 @@ Edit the URL in the Glitch below to see the part names. (You can also open this ## Glossary -### Anchor {: #anchor} - -See -[hash](#hash). - ### Country-code top-level domain (ccTLD) {: #cctld} A [top-level domain](#tld) defined in the From fd10479bc2e8ea170c71280caec20e41635d926a Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 13:22:44 +0000 Subject: [PATCH 07/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Alexandra White --- src/site/content/en/blog/url/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index dedeb2e6342..2e3edba5e17 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -96,14 +96,14 @@ A complete address for a website or a server, that maps to an [IP address](https The FQDN for a URL does not include the [port](#port), even if the port is provided in the URL. {% endAside %} -### Hash {: #hash} +{: #anchor} -Also known as "anchor". +### Hash (or anchor) {: #hash} A string following a `#` character at the end of a URL that provides a [fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). -For example, the URL `https://example.com/cats#tabby` has the hash value (anchor) `tabby`. +For example, the URL `https://example.com/cats#tabby` has a hash value of `tabby`. [Spec](https://url.spec.whatwg.org/#dom-url-hash) • [API](https://developer.mozilla.org/docs/Web/API/URL/hash) From 0db8e483162d33135bbb22a13b09e0c5234b3836 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 13:26:17 +0000 Subject: [PATCH 08/33] Removed separate heading for 'query string' --- src/site/content/en/blog/url/index.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 2e3edba5e17..84f18a386d1 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -175,9 +175,6 @@ in the URL `https://example.com:443/tabby`, the port number is 443. [Spec](https://url.spec.whatwg.org/#dom-url-port) • [API](https://developer.mozilla.org/docs/Web/API/URL/port) -### Query string - -See [search](#search). ### Registrable domain {: #registrable-domain} @@ -206,9 +203,7 @@ URL. [Spec](https://url.spec.whatwg.org/#dom-url-protocol) • [API](https://developer.mozilla.org/docs/Web/API/URL/protocol) -### Search {: #search} - -Also known as 'query string'. +### Search (or 'query string') {: #search} A series of key/value pairs that represent [parameters](#parameter), at the end of a URL after a question mark. @@ -218,8 +213,6 @@ question mark. [Spec](https://url.spec.whatwg.org/#dom-url-search) • [API](https://developer.mozilla.org/docs/Web/API/URL/search) - - ### Second-level domain {: #sld} The domain before the [top-level domain](#tld): From 4c1a894e7a67d306571f55d4a13ea37121198013 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 15:13:21 +0000 Subject: [PATCH 09/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Barry Pollard --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 84f18a386d1..0f815c2da52 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -164,7 +164,7 @@ including the [search string](#search) or [hash](#hash). - For `example.github.io/README.md`, the pathname is `/README.md`. - For `example.com`, the pathname is an empty string. -The 'path' component of a URL is sometimes used to refer to the pathname without the filename. +The 'path' component of a URL is sometimes used to refer to the pathname without the filename. For example, in `https://example.com/foo/bar/page.html`, the 'path' is `/foo/bar`. [Spec](https://url.spec.whatwg.org/#dom-url-pathname) • [API](https://developer.mozilla.org/docs/Web/API/URL/pathname) From cb5ca0b7a37afb80b608b0ed83db89a890f67653 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 15:14:23 +0000 Subject: [PATCH 10/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Barry Pollard --- src/site/content/en/blog/url/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 0f815c2da52..e4b3f0c5ebd 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -173,6 +173,8 @@ The 'path' component of a URL is sometimes used to refer to the pathname without A string following a `:` in a URL providing an integer that identifies a network port. For example, in the URL `https://example.com:443/tabby`, the port number is 443. +For http, the default port is 80 and does not need to be provided. For https, the default port is 443 and does not need to be provided. + [Spec](https://url.spec.whatwg.org/#dom-url-port) • [API](https://developer.mozilla.org/docs/Web/API/URL/port) From 535043f1dccca581e05ec751a4ce8de67670c45e Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 15:15:22 +0000 Subject: [PATCH 11/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Barry Pollard --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index e4b3f0c5ebd..9c679d3166d 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -238,7 +238,7 @@ According to the [URL Standard](https://url.spec.whatwg.org/), site includes [sc - For an [eTLD](#tld) where only third-level registrations are allowed (such as `co.uk` or `github.io`): the scheme, the top-level domain ('public suffix') and the part of the domain name just before that. For example, for the URL `https://www.example.co.uk/foo`, the site is - `example.co.uk`. (Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` + `https://example.co.uk`. (Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` are also [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though they cannot be registered via a domain name registrar.) From ac9296318596820b35fb477870df04759cde5ee5 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 15:16:01 +0000 Subject: [PATCH 12/33] Update src/site/content/en/blog/url/index.md Co-authored-by: Barry Pollard --- src/site/content/en/blog/url/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 9c679d3166d..158fabe64b3 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -227,6 +227,7 @@ The domain before the [top-level domain](#tld): ### Site {: #site} +The concept of 'site' is important in terms of 'same site', as certain security restrictions apply to sub-domains that are considered the 'same site' even if they are not 'same origin'. {% Aside %} According to the [URL Standard](https://url.spec.whatwg.org/), site includes [scheme](#scheme). (See [discussion of 'same site'](https://github.com/whatwg/url/issues/448).) From ad0a7c0b95c8533483e4dfd3739720726076e23f Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Wed, 22 Feb 2023 15:33:06 +0000 Subject: [PATCH 13/33] Tweaked port and site --- src/site/content/en/blog/url/index.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 158fabe64b3..e85bf372c79 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -171,13 +171,13 @@ The 'path' component of a URL is sometimes used to refer to the pathname without ### Port {: #port} A string following a `:` in a URL providing an integer that identifies a network port. For example, -in the URL `https://example.com:443/tabby`, the port number is 443. +in the URL `https://example.com:1234/tabby`, the port number is 1234. -For http, the default port is 80 and does not need to be provided. For https, the default port is 443 and does not need to be provided. +For an HTTP URL, the default port is 80; for HTTPS, the default is 443. A URL does not need to specify the +port number, unless a non-default port is used. [Spec](https://url.spec.whatwg.org/#dom-url-port) • [API](https://developer.mozilla.org/docs/Web/API/URL/port) - ### Registrable domain {: #registrable-domain} - For a site with a single-part top-level domain such as `com` or `org`, the top-level domain @@ -227,10 +227,9 @@ The domain before the [top-level domain](#tld): ### Site {: #site} -The concept of 'site' is important in terms of 'same site', as certain security restrictions apply to sub-domains that are considered the 'same site' even if they are not 'same origin'. {% Aside %} According to the [URL Standard](https://url.spec.whatwg.org/), site includes [scheme](#scheme). -(See [discussion of 'same site'](https://github.com/whatwg/url/issues/448).) +(See [discussion of "same-site"](https://github.com/whatwg/url/issues/448).) {% endAside %} - For a site such as `https://example.com` with a single-part top-level domain: the scheme, plus @@ -243,8 +242,12 @@ According to the [URL Standard](https://url.spec.whatwg.org/), site includes [sc are also [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) though they cannot be registered via a domain name registrar.) -{% Aside %} Unlike [origin](#origin), site does not include [port](#port). + +{% Aside %} +The concept of "site" is important in terms of "same-site", as certain security restrictions apply to subdomains that are +considered "same-site" even if they are not "same-origin": [Understanding "same-site" and "same-origin"](/same-site-same-origin/) +provides further information. {% endAside %} ### Subdomain {: #subdomain} From b66f29222708788149121d2d25e8a63ae195f7c2 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Thu, 5 Oct 2023 12:35:05 +0100 Subject: [PATCH 14/33] Updated to fix Markdown glitches --- src/site/content/en/blog/url/index.md | 654 +++++++++++++++++--------- 1 file changed, 439 insertions(+), 215 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index e85bf372c79..1d1a474288a 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -1,296 +1,520 @@ --- title: What are the parts of a URL? -subhead: "What's the difference between a domain name, hostname, site and origin? This article explains." -authors: - - samdutton -date: 2023-02-22 +subhead: "What's the difference between a hostname, site and origin? What's an eTLD? This article explains." +authors: + - samdutton +date: 2023-10-05 hero: image/80mq7dk16vVEg8BBhsVe42n6zn82/EAQ6QLeBBonbpyqeGWPb.jpg -alt: -tags: +alt: +tags: - blog - html - network - privacy --- -Most of the time it's fine to be relaxed about naming websites and URLs. It's -usually OK to say things like "I bought a domain name" or "Our images are hosted on a different -site," even if that's not strictly true. +What's the difference between host, site and origin? What is an eTLD+1? This article explains. -However, in some contexts it's crucial to be accurate and specific when referring to the parts of a -URL. For example, when dealing with cookies, you need to understand the difference between -[site](#site) and [origin](#origin). This article is designed to help with that. +Most of the time it's fine to say things like "I bought a domain" or "Our images are hosted on a +different site", even if that's not strictly true. However, in some contexts it's necessary to be +more precise. For example, when dealing with cookies, you need to understand the difference between +[site](#site) and +[origin](#origin). -The explanations here are only intended as a guide: -[The URL Living Standard](https://url.spec.whatwg.org/) provides formal definitions of URL parts. +Names for URL parts are specified in a standard, which also defines a JavaScript API: -{% Aside %} -The named parts of a URL may coincide, but that doesn't mean they're equivalent! +- The [URL Standard](https://url.spec.whatwg.org/) defines URLs and related concepts to enable + engineers to build interoperable web browsers. +- The [URL API](https://developer.mozilla.org/docs/Web/API/URL_API) component of the standard + defines methods to provide access to parts of a URL string, such as the + [scheme](#scheme) or [origin](#heading=h.17kwt3yobyfm). -The [FQDN](#fqdn), [eTLD+1](#etld1), [hostname](#hostname) and [registrable domain](#registrable-domain) -may be the same for some URLs, but each term has a different meaning. -{% endAside %} +This article explains a range of terms used with HTTP or HTTPS URLs, but does not cover other types +of URL such as file or data URLs. For terms such as `host` and `origin`, accurate definitions are +inherently complex, so this article provides examples and links to the URL Standard, rather than +attempting full explanations. -Edit the URL in the Glitch below to see the part names. (You can also open this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me).) +Edit the URL in the Glitch below to see how parts of the URL string are named. You can also open +this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). {% Glitch 'url-parts' %} - - - - - -## Glossary - -### Country-code top-level domain (ccTLD) {: #cctld} - -A [top-level domain](#tld) defined in the -[ISO 3166-1 Country Codes list](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes). - -- For `https://example.com.au`, the ccTLD is `au`. - -### Domain name {: #domain-name} - -The parts of a URL separated by dots: everything after the [scheme](#scheme), but before the -[path](#pathname) or [port](#port) (if specified). - -- For `https://example.github.io/path`, the domain name is `example.github.io`. -- For `https://support.example.com.au:443`, the domain name is `support.example.com.au`. -- Each part of the domain name is known as a - [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en). - -### Effective top-level domain (eTLD) {: #etld} - -An entry in the [Public Suffix List](https://publicsuffix.org/list/), including a -[TLD](#tld) and a [second-level domain](#sld). - -- For example: `github.io`, `com.au`. - -### eTLD+1 {: #etld1} - -An [eTLD](#etld) -plus the subdomain that precedes it. - -- For example: `example.github.io`, `example.com.au`. - -### Fully-qualified domain name (FQDN) {: #fqdn} - -A complete address for a website or a server, that maps to an [IP address](https://en.wikipedia.org/wiki/IP_address). - -- For `https://example.com:443/cats` the FQDN is `example.com`. -- For `https://api.example.github.io`, the FQDN is `api.example.github.io`. - {% Aside %} -The FQDN for a URL does not include the [port](#port), even if the port is provided in the URL. -{% endAside %} - -{: #anchor} - -### Hash (or anchor) {: #hash} - -A string following a `#` character at the end of a URL that provides a -[fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). - -For example, the URL `https://example.com/cats#tabby` has a hash value of `tabby`. - -[Spec](https://url.spec.whatwg.org/#dom-url-hash) • [API](https://developer.mozilla.org/docs/Web/API/URL/hash) - -{% Aside 'important' %} -The hash value is not passed when an HTTP request is made to a server. +The [FQDN](#fqdn), +[eTLD+1](#etld1), +[hostname](#hostname) and +[registrable domain](#registrable-domain) +may be the same for some URLs, but each term has a different meaning. {% endAside %} -### Host {: #host} +## Country-code top-level domain (ccTLD) -The [domain name](#domain-name), followed by the port if defined. +A [top-level domain](#tld) defined in +the [ISO 3166-1 Country Codes list](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes). -- For `https://www.example.com:443/foo`, the host is `www.example.com:443`. -- For `https://support.example.github.io`, the host is `support.example.github.io`. +- For `https://example.com.au`, the ccTLD is [`au`](https://en.wikipedia.org/wiki/.au). +- For `https://example.io`, the ccTLD is [`io`](https://en.wikipedia.org/wiki/.io). -[Spec](https://url.spec.whatwg.org/#dom-url-host) • [API](https://developer.mozilla.org/docs/Web/API/URL/host) +## Domain name -### Hostname {: #hostname} +The parts of an HTTP or HTTPS URL separated by dots: everything after the [scheme](#scheme), but +before the [path](#pathname) or [port](#port) (if specified). Each part of the domain name is known +as a [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en). -Generally equivalent to [domain name](#domain-name), but see -[Host representation](https://url.spec.whatwg.org/#concept-domain) in the WHATWG URL standard for -more detail. + + + + + + + + + + + + + + + + + +
URLDomain name
https://example.github.io/pathexample.github.io
https://support.example.com.au:443support.example.com.au
-[Spec](https://url.spec.whatwg.org/#dom-url-hostname) • [API](https://developer.mozilla.org/docs/Web/API/URL/hostname) +## Effective top-level domain (eTLD) -{% Aside %} -Unlike [host](#host), the hostname of a URL does not include the [port](#port). -{% endAside %} +An entry in the [Public Suffix List](https://publicsuffix.org/list/), including a [TLD](#tld) and +(for eTLDs with multiple parts) additional domains below that: second-level, third-level, and so on. -### Origin {: #origin} - -The [scheme](#scheme) followed by the [host](#host). - -- For `https://www.example.com:443/foo`, the origin is `https://www.example.com:443`. -- For `https://support.example.github.io`, the origin is `https://support.example.github.io:443`. - -[Spec](https://url.spec.whatwg.org/#dom-url-origin) • [API](https://developer.mozilla.org/docs/Web/API/URL/origin) +- For example: `com`, `com.au`, `github.io`, `sa.edu.au`, `schools.nsw.edu.au`. {% Aside %} -Unlike [site](#site), origin includes the [port](#port) if provided in the URL. +As well as one-part and two-part eTLDs such as com, `com.au` or `github.io`, the Public +Suffix List also includes three-part, four-part and even five-part eTLDs. {% endAside %} -### Parameter {: #parameter} - -An item of data passed in a [search string](#search) (also known as a 'query string'). +## eTLD+1 -- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the search string has two - parameters: `pattern=tabby` and `mood=bonkers`. +See [registrable domain](#heading=h.71qyk9517te5). -[Spec](https://url.spec.whatwg.org/#dom-url-searchparams) • [API](https://developer.mozilla.org/docs/Web/API/URL/searchParams) +An [eTLD](#etld) plus the subdomain that precedes it. -### Pathname {: #pathname} +- For example: `example.com`, `example.com.au`, `example.github.io`, `example.sa.edu.au`, + `example.schools.nsw.edu.au`. -The part of a URL after the domain and port (if defined), including a filename (if defined) but not -including the [search string](#search) or [hash](#hash). +## Fragment (or hash) -- For `https://example.com:8000/search?q=tabby`, the pathname is `/search`. -- For `example.github.io/foo`, the pathname is `/foo`. -- For `example.github.io/README.md`, the pathname is `/README.md`. -- For `example.com`, the pathname is an empty string. - -The 'path' component of a URL is sometimes used to refer to the pathname without the filename. For example, in `https://example.com/foo/bar/page.html`, the 'path' is `/foo/bar`. - -[Spec](https://url.spec.whatwg.org/#dom-url-pathname) • [API](https://developer.mozilla.org/docs/Web/API/URL/pathname) - -### Port {: #port} - -A string following a `:` in a URL providing an integer that identifies a network port. For example, -in the URL `https://example.com:1234/tabby`, the port number is 1234. - -For an HTTP URL, the default port is 80; for HTTPS, the default is 443. A URL does not need to specify the -port number, unless a non-default port is used. +A string following a # character at the end of a URL that provides a +[fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). +(In [some contexts](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#anchor) +this is referred to as an "anchor".) -[Spec](https://url.spec.whatwg.org/#dom-url-port) • [API](https://developer.mozilla.org/docs/Web/API/URL/port) +- For example: the URL `https://example.com/cats#tabby` has a fragment identifier (hash) value + of `tabby`. -### Registrable domain {: #registrable-domain} +{% Aside "important" %} +The fragment (hash) value is not passed when an HTTP request is made to a server. +{% endAside %} -- For a site with a single-part top-level domain such as `com` or `org`, the top-level domain - and the [second-level domain](#sld) before it: for example, `example.com` or `example.org`. -- For a top-level domain where only third-level registration is allowed (i.e. entries in the - [Public Suffix List](https://publicsuffix.org/list/) such as `co.uk` and, `github.io`) the - two-part top-level domain ('public suffix') and the third-level domain name just before that: - for example, `example.co.uk` or `example.com.au`. +- [Spec](https://url.spec.whatwg.org/#dom-url-hash) +- [API](https://developer.mozilla.org/docs/Web/API/URL/hash) + +## Fully-qualified domain name (FQDN) + +A complete address for a website or a server, that maps to an +[IP address](https://en.wikipedia.org/wiki/IP_address). + + + + + + + + + + + + + + + + + + +
URLFQDN
https://example.com:1234/catsexample.com
https://api.example.github.ioapi.example.github.io
+ +The FQDN for a URL does not include the [port](#port), even if a non-default port is used. + +## Host + +As defined in the [URL Standard](https://url.spec.whatwg.org/#host-representation), a host can be a +[domain name](#domain-name), IP v4 address, IPv6 address, opaque host, or empty host. + +- The URL Standard definition of `host` does not include the [port](#port). +- [`URL.host`](https://developer.mozilla.org/en-US/docs/Web/API/URL/host) includes the port, unless +the port is the default for the scheme. +- [`URL.hostname`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) does not include +the port. + + + + + + + + + + + + + + + + + + + + + + +
URL
URL.host
https://www.example.com:443/cat
www.example.com
+// 443 is the default port for the scheme
https://www.example.com:1234/cat
www.example.com:1234
https://cat.example.github.io
cat.example.github.io
+ +- [Spec](https://url.spec.whatwg.org/#dom-url-host) +- [API](https://developer.mozilla.org/docs/Web/API/URL/host) + +## Hostname + +Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL Standard. See +[host representation](https://url.spec.whatwg.org/#concept-domain) for more detail. + +[`URL.hostname`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) returns the +[host](#host) without the [port](#port). + + + + + + + + + + + + + + + + + + + + + + +
URL
URL.hostname
https://www.example.com:443/cat
www.example.com
https://www.example.com:1234/cat
www.example.com
https://cat.example.github.io
cat.example.github.io
+ +- [Spec](https://url.spec.whatwg.org/#dom-url-hostname) +- [API](https://developer.mozilla.org/docs/Web/API/URL/hostname) + +## Origin + +The URL Standard [defines `origin`](https://url.spec.whatwg.org/#origin), and links to the [HTML +standard](https://html.spec.whatwg.org/multipage/browsers.html#concept-origin) for background. + +For HTTP or HTTPS URLs, [`URL.origin`](https://developer.mozilla.org/docs/Web/API/URL/origin) +returns the [scheme](#scheme), the [host](#host), and [port](#port) (unless the port is the default +for the scheme). + + + + + + + + + + + + + + + + + + + + + + +
URL
URL.origin
https://www.example.com:443/cat
https://www.example.com
https://www.example.com:1234/cat
https://www.example.com:1234
https://cat.example.github.io
https://cat.example.github.io
+ +- [Spec](https://url.spec.whatwg.org/#dom-url-origin) +- [API](https://developer.mozilla.org/docs/Web/API/URL/origin) + +## Parameter + +Not defined in the URL Standard, and not part of the URL API, but commonly used to refer to an item +of data passed in a [search string](#search) (also known as a "query string"). + +- For example: for `https://example.com/cats?pattern=tabby&mood=bonkers`, the search string has +two parameters: `pattern=tabby` and `mood=bonkers`. + +See also [URL.searchParams](https://developer.mozilla.org/docs/Web/API/URL/searchParams). + +## Pathname + +For an HTTP or HTTPS URL, the part after the domain and port (if defined), including a filename (if +defined) but not including the [search string](#search) or [hash](#hash). + + + + + + + + + + + + + + + + + + + + + + + + + + +
URL
URL.pathname
https://example.com
[empty string]
https://example.com:8000/search?q=tabby
/search
https://example.github.io/cat/pattern#tabby
/cat/pattern
https://example.github.io/README.md
/README.md
+ +"Path" is sometimes used to refer to the pathname without the filename. For example, for the URL +`https://example.com/cat/pattern/tabby.html`, the "path" is `/cat/pattern`. + +- [Spec](https://url.spec.whatwg.org/#dom-url-pathname) +- [API](https://developer.mozilla.org/docs/Web/API/URL/pathname) + +## Port + +The number after a `:` in a URL that identifies a network port. For example: for the URL +`https://example.com:1234/tabby` the port number is 1234. + +The port number must be a [16-bit unsigned integer](https://url.spec.whatwg.org/#concept-url-port): +in other words, an integer between 0 and 65535 inclusive. + +For an HTTP URL, the default port is 80; for HTTPS, the default is 443. A URL does +not need to specify the port number unless a non-default port is used. + +The API returns an empty string if the port is the default for the scheme. + + + + + + + + + + + + + + + + + + + + + + +
URL
URL.port
https://example.com
// empty string
https://example.com:443/foo
// empty string: port is default for scheme
https://www.example.com:1234/foo
1234
+ +- [Spec](https://url.spec.whatwg.org/#dom-url-port) +- [API](https://developer.mozilla.org/docs/Web/API/URL/port) + +## Registrable domain + +- For a URL with a single-part [eTLD](#etld) such as `com` or `org` (i.e. an + eTLD that corresponds to a [TLD](#heading=h.gpxwuj9dkj1o)), the domain and the + [second-level domain](#sld) before it: for example, `example.com` or `example.org`. +- For a URL with a two-part eTLD where only third-level registration is allowed (i.e. entries + in the [Public Suffix List](https://publicsuffix.org/list/) such as `com.au` and, `github.io`) + the two-part top-level domain ("public suffix") and the third-level domain name just before + that. For example: `example.com.au` or `example.github.io`. +- For eTLDs with three or more parts, the eTLD and the domain before that. {% Aside %} -Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` -are [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) -though they cannot be registered via a domain name registrar. +Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` are [defined +as "registrable domains"](https://url.spec.whatwg.org/#host-registrable-domain) though they +cannot be "registered" by a developer. GitHub and Glitch act as registrars for these examples. {% endAside %} -### Scheme {: #scheme} +## Scheme -The part of the URL (before `://`) that defines the [protocol](https://developer.mozilla.org/docs/Glossary/Protocol) -(or action to be taken by the user agent) when a request is made to a URL. For example, a request -to a URL with an `https` scheme should be made using the [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS). -For a request to a URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a -network protocol, the behaviour depends on the user agent. For example, when a user clicks on a -`mailto` link, the browser might open its default email application, using the values in the link -URL. +The part of the URL (before `://`) that defines the [network +protocol](https://developer.mozilla.org/docs/Glossary/Protocol) (or action to be taken by the user +agent) when a request is made to a URL. For example, a request to a URL with an `https` scheme +should be made using the [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS). For a request to a +URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a network protocol, +the behaviour depends on the user agent. For example, when a user clicks on a `mailto` link, most +browsers open their default email application, using the values in the link's `href` URL. -[Spec](https://url.spec.whatwg.org/#dom-url-protocol) • [API](https://developer.mozilla.org/docs/Web/API/URL/protocol) +- [Spec](https://url.spec.whatwg.org/#dom-url-protocol) +- [API](https://developer.mozilla.org/docs/Web/API/URL/protocol) -### Search (or 'query string') {: #search} +## Search (or "query string") A series of key/value pairs that represent [parameters](#parameter), at the end of a URL after a question mark. -- For `https://example.com/cats?pattern=tabby&mood=bonkers`, the search string is - `pattern=tabby&mood=bonkers`. - -[Spec](https://url.spec.whatwg.org/#dom-url-search) • [API](https://developer.mozilla.org/docs/Web/API/URL/search) + + + + + + + + + + + + + + + + + +
URLSearch
https://example.com/cats?pattern=tabby&mood=bonkerspattern=tabby&mood=bonkers
https://example.com/cats:443?pattern=tabbypattern=tabby
+ +See also [URL.searchParams](https://developer.mozilla.org/docs/Web/API/URL/searchParams). + +- [Spec](https://url.spec.whatwg.org/#dom-url-search) +- [API](https://developer.mozilla.org/docs/Web/API/URL/search) + +## Second-level domain + +The domain before a [top-level +domain](#tld). + +- For the URL `https://www.example.com`, the second-level domain is `example.com`, a +[subdomain](#subdomain) of the top-level domain `com`. -### Second-level domain {: #sld} - -The domain before the [top-level domain](#tld): - -- For the URL `https://www.example.com`, `example.com` is the second-level domain, a - [subdomain](#subdomain) of the top-level domain `com`. - For `https://example.com.au`, the top-level domain is `au`, the second-level domain is `com` - and the third-level domain is `example`. In this example, `com.au` is a subdomain of `au` and - `example.com.au` is a subdomain of `com.au`. - -### Site {: #site} - -{% Aside %} -According to the [URL Standard](https://url.spec.whatwg.org/), site includes [scheme](#scheme). -(See [discussion of "same-site"](https://github.com/whatwg/url/issues/448).) -{% endAside %} - -- For a site such as `https://example.com` with a single-part top-level domain: the scheme, plus - the top-level domain and the part before that. For example, for the URL - `https://www.example.com/foo`, the site is `https://example.com`. -- For an [eTLD](#tld) where only third-level registrations are allowed (such as `co.uk` or - `github.io`): the scheme, the top-level domain ('public suffix') and the part of the domain name - just before that. For example, for the URL `https://www.example.co.uk/foo`, the site is - `https://example.co.uk`. (Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` - are also [defined as 'registrable domains'](https://url.spec.whatwg.org/#host-registrable-domain) - though they cannot be registered via a domain name registrar.) +and the third-level domain is `example`. In this example, `com.au` is a subdomain of `au` and +`example.com.au` is a subdomain of `com.au`. + +## Site + +[Site](https://html.spec.whatwg.org/multipage/browsers.html#sites) is defined by the HTML standard, +along with [same-site](https://html.spec.whatwg.org/multipage/browsers.html#same-site), which +[includes scheme](https://github.com/whatwg/url/issues/448), and +[schemeless same-site](https://html.spec.whatwg.org/multipage/browsers.html#schemelessly-same-site). | +Site is not defined in the URL standard or the URL JavaScript API. + +In this context: + +- For an HTTP or HTTPS URL with a single-part [eTLD](#tld) such as + `https://example.com`, the site consists of the `scheme`, the eTLD and the + [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en) before that. For example: + for the URL `https://www.example.com/cat`, the site is `https://example.com`. (For this URL, + the eTLD is the same as the [top-level domain](#heading=h.gpxwuj9dkj1o).) +- For multipart [eTLD](#tld)s such as `co.uk`, `github.io` or `sa.edu.au`, the "site" consists of + the `scheme`, the [eTLD](#tld) and the + [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en) before that. For example: + for the URL `https://cat.example.co.uk/tabby`, the site is `https://example.co.uk`, and for + `https://www.education.sa.gov.au` the site is `https://education.sa.gov.au`. + + + + + + + + + + + + + + + + + + +
URLSite (with scheme)
https://cat.example.com/tabbyhttps://example.com
https://cat.example.co.uk/tabbyhttps://example.co.uk
Unlike [origin](#origin), site does not include [port](#port). {% Aside %} -The concept of "site" is important in terms of "same-site", as certain security restrictions apply to subdomains that are -considered "same-site" even if they are not "same-origin": [Understanding "same-site" and "same-origin"](/same-site-same-origin/) -provides further information. +The concept of "site" is important in terms of "same-site", as certain security restrictions +apply to subdomains that are considered "same-site" even if they are not "same-origin": +[Understanding "same-site" and "same-origin"](https://deploy-preview-9613--web-dev-staging.netlify.app/same-site-same-origin/) provides further information. {% endAside %} -### Subdomain {: #subdomain} +## Subdomain A domain within a higher-level domain. -For sites with single-part top-level domains such as `.com` or `.org`, the parts before the -top-level domain, each of which is separated by a dot. +For sites with single-part top-level domains such as `com` or `org`, the parts before the top-level +domain, each of which is separated by a dot. + - `www.example.com` is a subdomain of `example.com`. -- `support.api.example.org` is a subdomain of `api.example.org`, which is a subdomain - of `example.org`. +- `support.api.example.org` is a subdomain of `api.example.org`, which is a subdomain of + `example.org`. -For top-level domains where only third-level registrations are allowed (i.e. entries in the -[Public Suffix List](https://publicsuffix.org/list/) such as co.uk and github.io) the parts of -the domain name before that. -- For example, `support.example.co.uk` is a subdomain of `example.co.uk`. +For two-part eTLDs where only third-level registrations are allowed (i.e. entries in the [Public +Suffix List](https://publicsuffix.org/list/) such as `co.uk` and `github.io`) the subdomains are the +parts of the domain name before that. -### Top-level domain (TLD) {: #tld} +- For example: `cat.example.co.uk` is a subdomain of `example.co.uk`. -- A domain name listed in the [Root Zone Database](https://www.iana.org/domains/root/db) such - as `com`, `io` or `org`. -- Some top-level domains are [country code top-level domains](#cctld), such as -[`uk`](https://www.iana.org/domains/root/db/uk.html) and +## Top-level domain (TLD) + +A domain name listed in the [Root Zone Database](https://www.iana.org/domains/root/db) such as +`com`, `io` or `org`. Some top-level domains are [country code top-level domains](#cctld), +such as [`uk`](https://www.iana.org/domains/root/db/uk.html) and [`tv`](https://www.iana.org/domains/root/db/tv.html). -When describing the parts of a URL, the domain name that follows the final dot. +When describing the parts of an HTTP or HTTPS URL, the TLD is the domain name that follows the final +dot. + - For `https://example.com`, the URL's top-level domain is `com`. - For `https://example.com.au`, the URL's top-level domain is `au`, and `com` is a -[second-level domain](#sld) (even though `com` is also a potential top-level domain!) +[second-level domain](#sld) (even though `com` is also a top-level domain). `com.au `is a two-part +[eTLD](#etld). + +The [Public Suffix List](https://publicsuffix.org/list/) of [eTLD](#etld)s includes domains with +one, two or more parts, so a TLD can also be an eTLD. For example: + +- For `https://example.com`, the URL's eTLD is `com`, which is also a TLD`.` + +--- ## Find out more - [WHATWG: URL Living Standard](https://url.spec.whatwg.org/) +- [WHATWG: HTML Living Standard](https://html.spec.whatwg.org/) - [URL API](https://developer.mozilla.org/docs/Web/API/URL_API) -- [Understanding "same-site" and "same-origin"](/same-site-same-origin/) +- [Understanding "same-site" and "same-origin"](https://deploy-preview-9613--web-dev-staging.netlify.app/same-site-same-origin/) - [RFC: Uniform Resource Locators (URL)](https://www.rfc-editor.org/rfc/rfc1738) - [RFC: URIs, URLs and URNs](https://datatracker.ietf.org/doc/html/rfc3305) -- [Root Zone Database](https://www.iana.org/domains/root/db) (directory of [TLDs](#tld)) -- [Public Suffix List](https://publicsuffix.org/list/) (directory of [eTLDs](#etld)) +- [Root Zone Database](https://www.iana.org/domains/root/db) (directory of + [TLDs](#tld)) +- [Public Suffix List](https://publicsuffix.org/list/) (directory of + [eTLDs](#etld): "A public suffix + is a set of DNS names or wildcards concatenated with dots. It represents the part of a domain + name which is not under the control of the individual registrant.") - [ICANN glossary](https://www.icann.org/en/icann-acronyms-and-terms?nav-letter=r&page=1) - [What is a Fully Qualified Domain Name?](https://datatracker.ietf.org/doc/html/rfc1594#section-5) - [How many ways can you slice a URL and name the pieces?](https://tantek.com/2011/238/b1/many-ways-slice-url-name-pieces) +- [MDN Web Docs Glossary](https://developer.mozilla.org/docs/Glossary) +- [What is a URL?](https://developer.mozilla.org/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL) - - -Photo by [Mathyas Kurmann](https://unsplash.com/@mathyaskurmann) on [Unsplash](https://unsplash.com/photos/fb7yNPbT0l8). +Photo by [Mathyas Kurmann](https://unsplash.com/@mathyaskurmann) on +[Unsplash](https://unsplash.com/photos/fb7yNPbT0l8). \ No newline at end of file From da2901eb22f51fe87140f6148d36332378a747a1 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Thu, 5 Oct 2023 12:36:21 +0100 Subject: [PATCH 15/33] Fixed MDN links --- src/site/content/en/blog/url/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 1d1a474288a..ccc4dfacf8b 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -105,7 +105,7 @@ An [eTLD](#etld) plus the subdomain that precedes it. A string following a # character at the end of a URL that provides a [fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). -(In [some contexts](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#anchor) +(In [some contexts](https://developer.mozilla.org/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#anchor) this is referred to as an "anchor".) - For example: the URL `https://example.com/cats#tabby` has a fragment identifier (hash) value @@ -150,9 +150,9 @@ As defined in the [URL Standard](https://url.spec.whatwg.org/#host-representatio [domain name](#domain-name), IP v4 address, IPv6 address, opaque host, or empty host. - The URL Standard definition of `host` does not include the [port](#port). -- [`URL.host`](https://developer.mozilla.org/en-US/docs/Web/API/URL/host) includes the port, unless +- [`URL.host`](https://developer.mozilla.org/docs/Web/API/URL/host) includes the port, unless the port is the default for the scheme. -- [`URL.hostname`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) does not include +- [`URL.hostname`](https://developer.mozilla.org/docs/Web/API/URL/hostname) does not include the port. @@ -187,7 +187,7 @@ the port. Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL Standard. See [host representation](https://url.spec.whatwg.org/#concept-domain) for more detail. -[`URL.hostname`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) returns the +[`URL.hostname`](https://developer.mozilla.org/docs/Web/API/URL/hostname) returns the [host](#host) without the [port](#port).
From bc304f3531c09fa6abdaebb1800b1635d9fe5297 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Thu, 5 Oct 2023 17:20:54 +0100 Subject: [PATCH 16/33] Minor tweaks to language --- src/site/content/en/blog/url/index.md | 69 ++++++++++++++------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index ccc4dfacf8b..7c240c71ed3 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -29,7 +29,7 @@ Names for URL parts are specified in a standard, which also defines a JavaScript defines methods to provide access to parts of a URL string, such as the [scheme](#scheme) or [origin](#heading=h.17kwt3yobyfm). -This article explains a range of terms used with HTTP or HTTPS URLs, but does not cover other types +This article explains a range of terms used with HTTP or HTTPS URLs. It does not cover other types of URL such as file or data URLs. For terms such as `host` and `origin`, accurate definitions are inherently complex, so this article provides examples and links to the URL Standard, rather than attempting full explanations. @@ -159,22 +159,22 @@ the port. - + - + - + - +
URL
URL.host
URL.host
https://www.example.com:443/cat
www.example.com
-// 443 is the default port for the scheme
www.example.com +// 443 is the default port for the scheme
https://www.example.com:1234/cat
www.example.com:1234
www.example.com:1234
https://cat.example.github.io
cat.example.github.io
cat.example.github.io
@@ -194,21 +194,21 @@ Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL St URL -
URL.hostname
+ URL.hostname https://www.example.com:443/cat -
www.example.com
+ www.example.com https://www.example.com:1234/cat -
www.example.com
+ www.example.com https://cat.example.github.io -
cat.example.github.io
+ cat.example.github.io @@ -229,21 +229,21 @@ for the scheme). URL -
URL.origin
+ URL.origin https://www.example.com:443/cat -
https://www.example.com
+ https://www.example.com https://www.example.com:1234/cat -
https://www.example.com:1234
+ https://www.example.com:1234 https://cat.example.github.io -
https://cat.example.github.io
+ https://cat.example.github.io @@ -270,25 +270,25 @@ defined) but not including the [search string](#search) or [hash](#hash). URL -
URL.pathname
+ URL.pathname https://example.com -
[empty string]
+ [empty string] https://example.com:8000/search?q=tabby -
/search
+ /search https://example.github.io/cat/pattern#tabby -
/cat/pattern
+ /cat/pattern https://example.github.io/README.md -
/README.md
+ /README.md @@ -316,21 +316,21 @@ The API returns an empty string if the port is the default for the scheme. URL -
URL.port
+ URL.port https://example.com -
// empty string
+ // empty string https://example.com:443/foo -
// empty string: port is default for scheme
+ // empty string: port is default for scheme https://www.example.com:1234/foo -
1234
+ 1234 @@ -361,8 +361,7 @@ The part of the URL (before `://`) that defines the [network protocol](https://developer.mozilla.org/docs/Glossary/Protocol) (or action to be taken by the user agent) when a request is made to a URL. For example, a request to a URL with an `https` scheme should be made using the [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS). For a request to a -URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a network protocol, -the behaviour depends on the user agent. For example, when a user clicks on a `mailto` link, most +URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a network protocol, behavior depends on the user agent. For example, when a user clicks on a `mailto` link, most browsers open their default email application, using the values in the link's `href` URL. - [Spec](https://url.spec.whatwg.org/#dom-url-protocol) @@ -370,24 +369,24 @@ browsers open their default email application, using the values in the link's `h ## Search (or "query string") -A series of key/value pairs that represent [parameters](#parameter), at the end of a URL after a -question mark. +A series of key/value pairs that represent [parameters](#parameter) and their values, at the end of +a URL after a question mark. - + - + - +
URLSearchURL.search
https://example.com/cats?pattern=tabby&mood=bonkerspattern=tabby&mood=bonkers?pattern=tabby&mood=bonkers
https://example.com/cats:443?pattern=tabbypattern=tabby?pattern=tabby
@@ -414,7 +413,7 @@ and the third-level domain is `example`. In this example, `com.au` is a subdomai [Site](https://html.spec.whatwg.org/multipage/browsers.html#sites) is defined by the HTML standard, along with [same-site](https://html.spec.whatwg.org/multipage/browsers.html#same-site), which [includes scheme](https://github.com/whatwg/url/issues/448), and -[schemeless same-site](https://html.spec.whatwg.org/multipage/browsers.html#schemelessly-same-site). | +[schemeless same-site](https://html.spec.whatwg.org/multipage/browsers.html#schemelessly-same-site). Site is not defined in the URL standard or the URL JavaScript API. In this context: @@ -452,11 +451,13 @@ In this context: Unlike [origin](#origin), site does not include [port](#port). {% Aside %} -The concept of "site" is important in terms of "same-site", as certain security restrictions -apply to subdomains that are considered "same-site" even if they are not "same-origin": +The concept of "site" is important in terms of "same-site", because certain security restrictions +apply to subdomains that are considered "same-site" even if they are not "same-origin". [Understanding "same-site" and "same-origin"](https://deploy-preview-9613--web-dev-staging.netlify.app/same-site-same-origin/) provides further information. {% endAside %} +- [Spec](https://html.spec.whatwg.org/multipage/browsers.html#sites) + ## Subdomain A domain within a higher-level domain. @@ -477,7 +478,7 @@ parts of the domain name before that. ## Top-level domain (TLD) A domain name listed in the [Root Zone Database](https://www.iana.org/domains/root/db) such as -`com`, `io` or `org`. Some top-level domains are [country code top-level domains](#cctld), +[`com`](https://www.iana.org/domains/root/db/com.html) or [`org`](https://www.iana.org/domains/root/db/org.html). Some top-level domains are [country code top-level domains](#cctld), such as [`uk`](https://www.iana.org/domains/root/db/uk.html) and [`tv`](https://www.iana.org/domains/root/db/tv.html). From cee42e0d9d5b61b9b23312540f7f11f6e45afd13 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 11:52:18 +0100 Subject: [PATCH 17/33] Tweaks --- src/site/content/en/blog/url/index.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 7c240c71ed3..ff0ffcb094a 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -1,6 +1,6 @@ --- title: What are the parts of a URL? -subhead: "What's the difference between a hostname, site and origin? What's an eTLD? This article explains." +subhead: "What's the difference between a host, site and origin? What's an eTLD? This article explains." authors: - samdutton date: 2023-10-05 @@ -13,7 +13,7 @@ tags: - privacy --- -What's the difference between host, site and origin? What is an eTLD+1? This article explains. +What's the difference between a host, site and origin? What is an eTLD+1? This article explains. Most of the time it's fine to say things like "I bought a domain" or "Our images are hosted on a different site", even if that's not strictly true. However, in some contexts it's necessary to be @@ -23,7 +23,7 @@ more precise. For example, when dealing with cookies, you need to understand the Names for URL parts are specified in a standard, which also defines a JavaScript API: -- The [URL Standard](https://url.spec.whatwg.org/) defines URLs and related concepts to enable +- The [URL standard](https://url.spec.whatwg.org/) defines URLs and related concepts to enable engineers to build interoperable web browsers. - The [URL API](https://developer.mozilla.org/docs/Web/API/URL_API) component of the standard defines methods to provide access to parts of a URL string, such as the @@ -31,7 +31,7 @@ Names for URL parts are specified in a standard, which also defines a JavaScript This article explains a range of terms used with HTTP or HTTPS URLs. It does not cover other types of URL such as file or data URLs. For terms such as `host` and `origin`, accurate definitions are -inherently complex, so this article provides examples and links to the URL Standard, rather than +inherently complex, so this article provides examples and links to the URL standard, rather than attempting full explanations. Edit the URL in the Glitch below to see how parts of the URL string are named. You can also open @@ -146,10 +146,10 @@ The FQDN for a URL does not include the [port](#port), even if a non-default por ## Host -As defined in the [URL Standard](https://url.spec.whatwg.org/#host-representation), a host can be a +As defined in the [URL standard](https://url.spec.whatwg.org/#host-representation), a host can be a [domain name](#domain-name), IP v4 address, IPv6 address, opaque host, or empty host. -- The URL Standard definition of `host` does not include the [port](#port). +- The URL standard's definition of `host` does not include the [port](#port). - [`URL.host`](https://developer.mozilla.org/docs/Web/API/URL/host) includes the port, unless the port is the default for the scheme. - [`URL.hostname`](https://developer.mozilla.org/docs/Web/API/URL/hostname) does not include @@ -184,7 +184,7 @@ the port. ## Hostname -Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL Standard. See +Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL standard. See [host representation](https://url.spec.whatwg.org/#concept-domain) for more detail. [`URL.hostname`](https://developer.mozilla.org/docs/Web/API/URL/hostname) returns the @@ -218,7 +218,7 @@ Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL St ## Origin -The URL Standard [defines `origin`](https://url.spec.whatwg.org/#origin), and links to the [HTML +The URL standard [defines `origin`](https://url.spec.whatwg.org/#origin), and links to the [HTML standard](https://html.spec.whatwg.org/multipage/browsers.html#concept-origin) for background. For HTTP or HTTPS URLs, [`URL.origin`](https://developer.mozilla.org/docs/Web/API/URL/origin) @@ -253,7 +253,7 @@ for the scheme). ## Parameter -Not defined in the URL Standard, and not part of the URL API, but commonly used to refer to an item +Not defined in the URL standard, and not part of the URL API, but commonly used to refer to an item of data passed in a [search string](#search) (also known as a "query string"). - For example: for `https://example.com/cats?pattern=tabby&mood=bonkers`, the search string has From 34b1f541bcaedf80d2f0fddfac0405e5f0cff1cd Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 12:10:28 +0100 Subject: [PATCH 18/33] Removed aside from beginning --- src/site/content/en/blog/url/index.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index ff0ffcb094a..72856351910 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -39,14 +39,6 @@ this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). {% Glitch 'url-parts' %} -{% Aside %} -The [FQDN](#fqdn), -[eTLD+1](#etld1), -[hostname](#hostname) and -[registrable domain](#registrable-domain) -may be the same for some URLs, but each term has a different meaning. -{% endAside %} - ## Country-code top-level domain (ccTLD) A [top-level domain](#tld) defined in From 5780e1a59017fdb7a7e83859c7881be929c5ec6f Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 12:58:43 +0100 Subject: [PATCH 19/33] Tweaks from suggestions by Tom --- src/site/content/en/blog/url/index.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 72856351910..b890fcf3d1c 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -34,6 +34,14 @@ of URL such as file or data URLs. For terms such as `host` and `origin`, accurat inherently complex, so this article provides examples and links to the URL standard, rather than attempting full explanations. +You can use JavaScript to get the names of the parts of a URL that are defined by the URL API. For example: + +```javascript +let url = new URL('https://foo.com.au:1234/bar/foo.html#bar'); +console.log(url); +``` + + Edit the URL in the Glitch below to see how parts of the URL string are named. You can also open this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). @@ -80,7 +88,7 @@ An entry in the [Public Suffix List](https://publicsuffix.org/list/), including - For example: `com`, `com.au`, `github.io`, `sa.edu.au`, `schools.nsw.edu.au`. {% Aside %} -As well as one-part and two-part eTLDs such as com, `com.au` or `github.io`, the Public +As well as one-part and two-part eTLDs such as `com`, `com.au` or `github.io`, the Public Suffix List also includes three-part, four-part and even five-part eTLDs. {% endAside %} @@ -107,6 +115,8 @@ this is referred to as an "anchor".) The fragment (hash) value is not passed when an HTTP request is made to a server. {% endAside %} +You can also link to and highlight a [text fragment](https://web.dev/text-fragments) within a document. For example, to link to the first occurrence of the text "fragment" in this article, use the URL `https://web.dev/url#:~:text=fragment`. + - [Spec](https://url.spec.whatwg.org/#dom-url-hash) - [API](https://developer.mozilla.org/docs/Web/API/URL/hash) @@ -136,6 +146,10 @@ A complete address for a website or a server, that maps to an The FQDN for a URL does not include the [port](#port), even if a non-default port is used. +## Hash + +(See [fragment](#fragment).) + ## Host As defined in the [URL standard](https://url.spec.whatwg.org/#host-representation), a host can be a From 1c546524ae13a99d4fca4f9b759f936d808792f4 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 12:59:26 +0100 Subject: [PATCH 20/33] Tweaks --- src/site/content/en/blog/url/index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index b890fcf3d1c..4f885f0926e 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -41,7 +41,6 @@ let url = new URL('https://foo.com.au:1234/bar/foo.html#bar'); console.log(url); ``` - Edit the URL in the Glitch below to see how parts of the URL string are named. You can also open this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). From 46b1b5670bed8c8e489f80022fc034eba369e28b Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 13:24:38 +0100 Subject: [PATCH 21/33] Fixed internal hash URLs and added back anchors --- src/site/content/en/blog/url/index.md | 84 ++++++++++++++------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 4f885f0926e..fad69ab8efb 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -27,14 +27,14 @@ Names for URL parts are specified in a standard, which also defines a JavaScript engineers to build interoperable web browsers. - The [URL API](https://developer.mozilla.org/docs/Web/API/URL_API) component of the standard defines methods to provide access to parts of a URL string, such as the - [scheme](#scheme) or [origin](#heading=h.17kwt3yobyfm). + [scheme](#scheme) or [origin](#origin). This article explains a range of terms used with HTTP or HTTPS URLs. It does not cover other types of URL such as file or data URLs. For terms such as `host` and `origin`, accurate definitions are inherently complex, so this article provides examples and links to the URL standard, rather than attempting full explanations. -You can use JavaScript to get the names of the parts of a URL that are defined by the URL API. For example: +You can use JavaScript to get the names of URL components that are defined by the URL API. For example: ```javascript let url = new URL('https://foo.com.au:1234/bar/foo.html#bar'); @@ -46,7 +46,7 @@ this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). {% Glitch 'url-parts' %} -## Country-code top-level domain (ccTLD) +## Country-code top-level domain (ccTLD) {: #cctld} A [top-level domain](#tld) defined in the [ISO 3166-1 Country Codes list](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes). @@ -54,7 +54,7 @@ the [ISO 3166-1 Country Codes list](https://en.wikipedia.org/wiki/ISO_3166-1#Cur - For `https://example.com.au`, the ccTLD is [`au`](https://en.wikipedia.org/wiki/.au). - For `https://example.io`, the ccTLD is [`io`](https://en.wikipedia.org/wiki/.io). -## Domain name +## Domain name {: #domain-name} The parts of an HTTP or HTTPS URL separated by dots: everything after the [scheme](#scheme), but before the [path](#pathname) or [port](#port) (if specified). Each part of the domain name is known @@ -79,7 +79,7 @@ as a [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en). -## Effective top-level domain (eTLD) +## Effective top-level domain (eTLD) {: #etld} An entry in the [Public Suffix List](https://publicsuffix.org/list/), including a [TLD](#tld) and (for eTLDs with multiple parts) additional domains below that: second-level, third-level, and so on. @@ -89,18 +89,22 @@ An entry in the [Public Suffix List](https://publicsuffix.org/list/), including {% Aside %} As well as one-part and two-part eTLDs such as `com`, `com.au` or `github.io`, the Public Suffix List also includes three-part, four-part and even five-part eTLDs. + +Browser including [Chromium](https://chromium.googlesource.com/chromium/src/+/master/net/base/registry_controlled_domains/effective_tld_names.dat) +and [Firefox](https://github.com/mozilla/gecko-dev/blob/master/netwerk/dns/effective_tld_names.dat) +use the list in their builds. {% endAside %} -## eTLD+1 +## eTLD+1 {: #etld1} -See [registrable domain](#heading=h.71qyk9517te5). +See [registrable domain](#registrable-domain). An [eTLD](#etld) plus the subdomain that precedes it. - For example: `example.com`, `example.com.au`, `example.github.io`, `example.sa.edu.au`, `example.schools.nsw.edu.au`. -## Fragment (or hash) +## Fragment (or hash) {: #fragment} A string following a # character at the end of a URL that provides a [fragment identifier](https://developer.mozilla.org/docs/Learn/Common_questions/What_is_a_URL#anchor). @@ -119,7 +123,7 @@ You can also link to and highlight a [text fragment](https://web.dev/text-fragme - [Spec](https://url.spec.whatwg.org/#dom-url-hash) - [API](https://developer.mozilla.org/docs/Web/API/URL/hash) -## Fully-qualified domain name (FQDN) +## Fully-qualified domain name (FQDN) {: #fqdn} A complete address for a website or a server, that maps to an [IP address](https://en.wikipedia.org/wiki/IP_address). @@ -149,7 +153,7 @@ The FQDN for a URL does not include the [port](#port), even if a non-default por (See [fragment](#fragment).) -## Host +## Host {: #host} As defined in the [URL standard](https://url.spec.whatwg.org/#host-representation), a host can be a [domain name](#domain-name), IP v4 address, IPv6 address, opaque host, or empty host. @@ -187,7 +191,7 @@ the port. - [Spec](https://url.spec.whatwg.org/#dom-url-host) - [API](https://developer.mozilla.org/docs/Web/API/URL/host) -## Hostname +## Hostname {: #hostname} Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL standard. See [host representation](https://url.spec.whatwg.org/#concept-domain) for more detail. @@ -221,10 +225,10 @@ Hostname is defined by the JavaScript `URL` API, but not elsewhere by the URL st - [Spec](https://url.spec.whatwg.org/#dom-url-hostname) - [API](https://developer.mozilla.org/docs/Web/API/URL/hostname) -## Origin +## Origin {: #origin} -The URL standard [defines `origin`](https://url.spec.whatwg.org/#origin), and links to the [HTML -standard](https://html.spec.whatwg.org/multipage/browsers.html#concept-origin) for background. +The URL standard [defines `origin`](https://url.spec.whatwg.org/#origin), and links to the +[HTML standard](https://html.spec.whatwg.org/multipage/browsers.html#concept-origin) for background. For HTTP or HTTPS URLs, [`URL.origin`](https://developer.mozilla.org/docs/Web/API/URL/origin) returns the [scheme](#scheme), the [host](#host), and [port](#port) (unless the port is the default @@ -256,7 +260,7 @@ for the scheme). - [Spec](https://url.spec.whatwg.org/#dom-url-origin) - [API](https://developer.mozilla.org/docs/Web/API/URL/origin) -## Parameter +## Parameter {: #parameter} Not defined in the URL standard, and not part of the URL API, but commonly used to refer to an item of data passed in a [search string](#search) (also known as a "query string"). @@ -266,7 +270,7 @@ two parameters: `pattern=tabby` and `mood=bonkers`. See also [URL.searchParams](https://developer.mozilla.org/docs/Web/API/URL/searchParams). -## Pathname +## Pathname {: #pathname} For an HTTP or HTTPS URL, the part after the domain and port (if defined), including a filename (if defined) but not including the [search string](#search) or [hash](#hash). @@ -304,7 +308,7 @@ defined) but not including the [search string](#search) or [hash](#hash). - [Spec](https://url.spec.whatwg.org/#dom-url-pathname) - [API](https://developer.mozilla.org/docs/Web/API/URL/pathname) -## Port +## Port {: #port} The number after a `:` in a URL that identifies a network port. For example: for the URL `https://example.com:1234/tabby` the port number is 1234. @@ -343,10 +347,10 @@ The API returns an empty string if the port is the default for the scheme. - [Spec](https://url.spec.whatwg.org/#dom-url-port) - [API](https://developer.mozilla.org/docs/Web/API/URL/port) -## Registrable domain +## Registrable domain {: #registrable-domain} - For a URL with a single-part [eTLD](#etld) such as `com` or `org` (i.e. an - eTLD that corresponds to a [TLD](#heading=h.gpxwuj9dkj1o)), the domain and the + eTLD that corresponds to a [TLD](#tld)), the domain and the [second-level domain](#sld) before it: for example, `example.com` or `example.org`. - For a URL with a two-part eTLD where only third-level registration is allowed (i.e. entries in the [Public Suffix List](https://publicsuffix.org/list/) such as `com.au` and, `github.io`) @@ -355,24 +359,25 @@ The API returns an empty string if the port is the default for the scheme. - For eTLDs with three or more parts, the eTLD and the domain before that. {% Aside %} -Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` are [defined -as "registrable domains"](https://url.spec.whatwg.org/#host-registrable-domain) though they +Confusingly, perhaps, domains such as `example.github.io` or `example.glitch.me` are +[defined as "registrable domains"](https://url.spec.whatwg.org/#host-registrable-domain) though they cannot be "registered" by a developer. GitHub and Glitch act as registrars for these examples. {% endAside %} -## Scheme +## Scheme {: #scheme} -The part of the URL (before `://`) that defines the [network -protocol](https://developer.mozilla.org/docs/Glossary/Protocol) (or action to be taken by the user -agent) when a request is made to a URL. For example, a request to a URL with an `https` scheme -should be made using the [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS). For a request to a -URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a network protocol, behavior depends on the user agent. For example, when a user clicks on a `mailto` link, most -browsers open their default email application, using the values in the link's `href` URL. +The part of the URL (before `://`) that defines the +[network protocol](https://developer.mozilla.org/docs/Glossary/Protocol) (or action to be taken by +the user agent) when a request is made to a URL. For example, a request to a URL with an `https` +scheme should be made using the [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS). For a request +to a URL with a scheme such as `file`, `mailto` or `git` that doesn't correspond to a network +protocol, behavior depends on the user agent. For example, when a user clicks on a `mailto` link, +most browsers open their default email application, using the values in the link's `href` URL. - [Spec](https://url.spec.whatwg.org/#dom-url-protocol) - [API](https://developer.mozilla.org/docs/Web/API/URL/protocol) -## Search (or "query string") +## Search (or "query string") {: #search} A series of key/value pairs that represent [parameters](#parameter) and their values, at the end of a URL after a question mark. @@ -401,10 +406,9 @@ See also [URL.searchParams](https://developer.mozilla.org/docs/Web/API/URL/searc - [Spec](https://url.spec.whatwg.org/#dom-url-search) - [API](https://developer.mozilla.org/docs/Web/API/URL/search) -## Second-level domain +## Second-level domain {: #sld} -The domain before a [top-level -domain](#tld). +The domain before a [top-level domain](#tld). - For the URL `https://www.example.com`, the second-level domain is `example.com`, a [subdomain](#subdomain) of the top-level domain `com`. @@ -413,7 +417,7 @@ domain](#tld). and the third-level domain is `example`. In this example, `com.au` is a subdomain of `au` and `example.com.au` is a subdomain of `com.au`. -## Site +## Site {: #site} [Site](https://html.spec.whatwg.org/multipage/browsers.html#sites) is defined by the HTML standard, along with [same-site](https://html.spec.whatwg.org/multipage/browsers.html#same-site), which @@ -427,7 +431,7 @@ In this context: `https://example.com`, the site consists of the `scheme`, the eTLD and the [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en) before that. For example: for the URL `https://www.example.com/cat`, the site is `https://example.com`. (For this URL, - the eTLD is the same as the [top-level domain](#heading=h.gpxwuj9dkj1o).) + the eTLD is the same as the [top-level domain](#tld).) - For multipart [eTLD](#tld)s such as `co.uk`, `github.io` or `sa.edu.au`, the "site" consists of the `scheme`, the [eTLD](#tld) and the [label](https://www.icann.org/en/icann-acronyms-and-terms/label-en) before that. For example: @@ -463,7 +467,7 @@ apply to subdomains that are considered "same-site" even if they are not "same-o - [Spec](https://html.spec.whatwg.org/multipage/browsers.html#sites) -## Subdomain +## Subdomain {: #subdomain} A domain within a higher-level domain. @@ -474,13 +478,13 @@ domain, each of which is separated by a dot. - `support.api.example.org` is a subdomain of `api.example.org`, which is a subdomain of `example.org`. -For two-part eTLDs where only third-level registrations are allowed (i.e. entries in the [Public -Suffix List](https://publicsuffix.org/list/) such as `co.uk` and `github.io`) the subdomains are the -parts of the domain name before that. +For two-part eTLDs where only third-level registrations are allowed (i.e. entries in the +[Public Suffix List](https://publicsuffix.org/list/) such as `co.uk` and `github.io`) the subdomains +are the parts of the domain name before that. - For example: `cat.example.co.uk` is a subdomain of `example.co.uk`. -## Top-level domain (TLD) +## Top-level domain (TLD) {: #tld} A domain name listed in the [Root Zone Database](https://www.iana.org/domains/root/db) such as [`com`](https://www.iana.org/domains/root/db/com.html) or [`org`](https://www.iana.org/domains/root/db/org.html). Some top-level domains are [country code top-level domains](#cctld), @@ -502,7 +506,7 @@ one, two or more parts, so a TLD can also be an eTLD. For example: --- -## Find out more +## Find out more {: #more} - [WHATWG: URL Living Standard](https://url.spec.whatwg.org/) - [WHATWG: HTML Living Standard](https://html.spec.whatwg.org/) From 41fd18d07006f239907f1c4d3e1e0081e051fdce Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 13:25:37 +0100 Subject: [PATCH 22/33] Fix --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index fad69ab8efb..98114c96302 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -118,7 +118,7 @@ this is referred to as an "anchor".) The fragment (hash) value is not passed when an HTTP request is made to a server. {% endAside %} -You can also link to and highlight a [text fragment](https://web.dev/text-fragments) within a document. For example, to link to the first occurrence of the text "fragment" in this article, use the URL `https://web.dev/url#:~:text=fragment`. +You can also link to and highlight a [text fragment](/text-fragments) within a document. For example, to link to the first occurrence of the text "fragment" in this article, use the URL `https://web.dev/url#:~:text=fragment`. - [Spec](https://url.spec.whatwg.org/#dom-url-hash) - [API](https://developer.mozilla.org/docs/Web/API/URL/hash) From e70ade01b66c837d8a807447f722ac6a5afa7aff Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 13:43:18 +0100 Subject: [PATCH 23/33] Doh --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 98114c96302..535c632d564 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -90,7 +90,7 @@ An entry in the [Public Suffix List](https://publicsuffix.org/list/), including As well as one-part and two-part eTLDs such as `com`, `com.au` or `github.io`, the Public Suffix List also includes three-part, four-part and even five-part eTLDs. -Browser including [Chromium](https://chromium.googlesource.com/chromium/src/+/master/net/base/registry_controlled_domains/effective_tld_names.dat) +Browsers including [Chromium](https://chromium.googlesource.com/chromium/src/+/master/net/base/registry_controlled_domains/effective_tld_names.dat) and [Firefox](https://github.com/mozilla/gecko-dev/blob/master/netwerk/dns/effective_tld_names.dat) use the list in their builds. {% endAside %} From e1268be7b4a87cdda5a88c9779b1bc7924ea00b3 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:43:33 +0100 Subject: [PATCH 24/33] Removed redundant first sentence --- src/site/content/en/blog/url/index.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 535c632d564..0d109fa53a1 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -13,8 +13,6 @@ tags: - privacy --- -What's the difference between a host, site and origin? What is an eTLD+1? This article explains. - Most of the time it's fine to say things like "I bought a domain" or "Our images are hosted on a different site", even if that's not strictly true. However, in some contexts it's necessary to be more precise. For example, when dealing with cookies, you need to understand the difference between @@ -86,13 +84,17 @@ An entry in the [Public Suffix List](https://publicsuffix.org/list/), including - For example: `com`, `com.au`, `github.io`, `sa.edu.au`, `schools.nsw.edu.au`. +A "public suffix", such as these examples, is a name under which domains can be registered. The Public Suffix List is a list of all known public suffixes, and is frequently updated. Browsers including [Chromium](https://chromium.googlesource.com/chromium/src/+/master/net/base/registry_controlled_domains/effective_tld_names.dat) +and [Firefox](https://github.com/mozilla/gecko-dev/blob/master/netwerk/dns/effective_tld_names.dat) +use the list in their builds. + {% Aside %} As well as one-part and two-part eTLDs such as `com`, `com.au` or `github.io`, the Public Suffix List also includes three-part, four-part and even five-part eTLDs. -Browsers including [Chromium](https://chromium.googlesource.com/chromium/src/+/master/net/base/registry_controlled_domains/effective_tld_names.dat) -and [Firefox](https://github.com/mozilla/gecko-dev/blob/master/netwerk/dns/effective_tld_names.dat) -use the list in their builds. +The list also includes suffixes such as `github.io` and `glitch.me`. Names under these, such as +`example.github.io` and `example.glitch.me`, can be used for site hosting but cannot be "registered" +by a developer with a commercial domain registrar. GitHub and Glitch act as registrars in these examples. {% endAside %} ## eTLD+1 {: #etld1} @@ -151,7 +153,7 @@ The FQDN for a URL does not include the [port](#port), even if a non-default por ## Hash -(See [fragment](#fragment).) +See [fragment](#fragment). ## Host {: #host} From 3897daf6bdf485f0acff274c87875225e1122365 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:45:14 +0100 Subject: [PATCH 25/33] Tweak --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 0d109fa53a1..8eb9535541f 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -27,7 +27,7 @@ Names for URL parts are specified in a standard, which also defines a JavaScript defines methods to provide access to parts of a URL string, such as the [scheme](#scheme) or [origin](#origin). -This article explains a range of terms used with HTTP or HTTPS URLs. It does not cover other types +This article explains a range of terms used with HTTP or HTTPS URL strings. It does not cover other types of URL such as file or data URLs. For terms such as `host` and `origin`, accurate definitions are inherently complex, so this article provides examples and links to the URL standard, rather than attempting full explanations. From 58eb3dca155c94c3f91a4e18028499cc0e6cfbed Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:47:25 +0100 Subject: [PATCH 26/33] Tweak --- src/site/content/en/blog/url/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 8eb9535541f..3ba760bb5b1 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -44,6 +44,8 @@ this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). {% Glitch 'url-parts' %} +Names used for URL parts are listed alphabetically below. + ## Country-code top-level domain (ccTLD) {: #cctld} A [top-level domain](#tld) defined in From 3304465a058db09ed0e9c6e06e832440943698d1 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:49:56 +0100 Subject: [PATCH 27/33] Tweak --- src/site/content/en/blog/url/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 3ba760bb5b1..2240a9e23d8 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -44,7 +44,9 @@ this in a separate tab at [url-parts.glitch.me](https://url-parts.glitch.me/). {% Glitch 'url-parts' %} -Names used for URL parts are listed alphabetically below. +
+ +Names for URL parts are listed alphabetically below. ## Country-code top-level domain (ccTLD) {: #cctld} From beb1afda37804721f1d3b211d0b0e9ae3a3a8f7d Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:50:51 +0100 Subject: [PATCH 28/33] Tweak --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 2240a9e23d8..dcbdf77544f 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -98,7 +98,7 @@ Suffix List also includes three-part, four-part and even five-part eTLDs. The list also includes suffixes such as `github.io` and `glitch.me`. Names under these, such as `example.github.io` and `example.glitch.me`, can be used for site hosting but cannot be "registered" -by a developer with a commercial domain registrar. GitHub and Glitch act as registrars in these examples. +by a developer. GitHub and Glitch act as registrars in these examples. {% endAside %} ## eTLD+1 {: #etld1} From 8c9147be86a1d1c7632f5eaf638d725722085dfa Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:52:23 +0100 Subject: [PATCH 29/33] Tweak --- src/site/content/en/blog/url/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index dcbdf77544f..12bcedb8f18 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -179,8 +179,8 @@ the port. - https://www.example.com:443/cat - www.example.com + https://www.example.com:443/cat + www.example.com
// 443 is the default port for the scheme
From 88fe09b797b303b380ca74805741e2c30be86140 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 17:53:29 +0100 Subject: [PATCH 30/33] Tweak --- src/site/content/en/blog/url/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 12bcedb8f18..028221cd4d0 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -508,7 +508,7 @@ dot. The [Public Suffix List](https://publicsuffix.org/list/) of [eTLD](#etld)s includes domains with one, two or more parts, so a TLD can also be an eTLD. For example: -- For `https://example.com`, the URL's eTLD is `com`, which is also a TLD`.` +- For `https://example.com`, the URL's eTLD is `com`, which is also a TLD. --- From 0d8bc86ff710df3c49291ddf517eb4986d84baca Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 18:02:46 +0100 Subject: [PATCH 31/33] Doh --- src/site/content/en/blog/url/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 028221cd4d0..7b11940339d 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -179,8 +179,8 @@ the port. - https://www.example.com:443/cat - www.example.com
+ https://www.example.com:443/cat + www.example.com
// 443 is the default port for the scheme
@@ -502,7 +502,7 @@ dot. - For `https://example.com`, the URL's top-level domain is `com`. - For `https://example.com.au`, the URL's top-level domain is `au`, and `com` is a -[second-level domain](#sld) (even though `com` is also a top-level domain). `com.au `is a two-part +[second-level domain](#sld) (even though `com` is also a top-level domain). `com.au` is a two-part [eTLD](#etld). The [Public Suffix List](https://publicsuffix.org/list/) of [eTLD](#etld)s includes domains with From ad77528c81aa8debdcb926ede017846ea1769e20 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 18:05:00 +0100 Subject: [PATCH 32/33] Doh --- src/site/content/en/blog/url/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 7b11940339d..8e67215321f 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -179,8 +179,8 @@ the port. - https://www.example.com:443/cat - www.example.com
+ https://www.example.com:443/cat + www.example.com
// 443 is the default port for the scheme
From 8f9a654ad0c32a0697e13db5009cfa12bbfa17a4 Mon Sep 17 00:00:00 2001 From: Sam Dutton Date: Fri, 6 Oct 2023 18:10:36 +0100 Subject: [PATCH 33/33] Double doh --- src/site/content/en/blog/url/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/content/en/blog/url/index.md b/src/site/content/en/blog/url/index.md index 8e67215321f..05c9c214382 100644 --- a/src/site/content/en/blog/url/index.md +++ b/src/site/content/en/blog/url/index.md @@ -179,8 +179,8 @@ the port. - https://www.example.com:443/cat - www.example.com
+ https://www.example.com:443/cat + www.example.com
// 443 is the default port for the scheme