- From: Uku Sõrmus <notifications@github.com>
- Date: Mon, 07 Apr 2025 01:51:57 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/869@github.com>
ukusormus created an issue (whatwg/url#869) ### What is the issue with the URL Standard? The usage of the term "hostname" could be clarified in the spec, because the popular usage of the term ("domain name") and URL IDL usage of the term ("domain name or IP address") seem to clash. ### Popular usage In popular usage, as far as I can see, "hostname" seems to refer to a **DNS domain name**. E.g., from [Wikipedia](https://en.wikipedia.org/wiki/Hostname): > [...] a hostname is also called a [domain name](https://en.wikipedia.org/wiki/Domain_name) Also see RFCs related to DNS, e.g. [section 2.1 of RFC1123](https://datatracker.ietf.org/doc/html/rfc1123#section-2) (emphasis mine): > However, **a valid host name can never have the dotted-decimal form #.#.#.#**, since at least the highest-level component label will be alphabetic. Or [RFC1034](https://datatracker.ietf.org/doc/html/rfc1034#section-2.1), referenced by WHATWG URL spec itself in ["domain" concept](https://url.spec.whatwg.org/#concept-domain): > Host name to address mappings [...] (sidenote: an interesting language quirk: "hostname" v.s. "host name") ### URL spec usage In the [current version](https://github.com/whatwg/url/blob/cc8b776b89a6d92b5cc74581c8d90450d3c1e762/url.bs#L3695) of the WHATWG URL spec, the term "hostname" seems to refer to the term "host" as defined by the spec itself, i.e., **domain *or* IP address** (I'm not counting edge-cases like opaque host here for simplicity). Note that "IP address" was added to the mix of "hostname", while popular usage uses "hostname" (or "host name") as a mapping to "IP address", *not as (including)* an IP address. I can find the usage of "hostname" in two places in the URL spec: 1. `hostname state` as an alias `host state` (as having caused confusion in #681) 2. URL class `hostname` attribute getter and setter Focusing on the second place it is used: ``` A host is a domain, an IP address, [...] ... The hostname getter steps are: ... Return this’s URL’s host, serialized. ``` Or more practically: ```js new URL("http://site.example:1234").hostname // "site.example" new URL("http://127.0.0.1:1234").hostname // "127.0.0.1" ``` That is, the last case of an IP address being considered a "hostname" is not in sync with popular usage. ### Possible resolution Maybe a note explaining, e.g., "it's just the historical reasons the URL API acts this way", would avoid confusion amongst the readers between terms like "host" and "hostname". -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/url/issues/869 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/url/issues/869@github.com>
Received on Monday, 7 April 2025 08:52:02 UTC