Skip to content

Usage of the term "hostname" may need clarifications as it clashes with popular usage #869

@ukusormus

Description

@ukusormus

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:

[...] a hostname is also called a domain name

Also see RFCs related to DNS, e.g. section 2.1 of RFC1123 (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, referenced by WHATWG URL spec itself in "domain" concept:

Host name to address mappings [...]

(sidenote: an interesting language quirk: "hostname" v.s. "host name")

URL spec usage

In the current version 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 Clarify whether "host state" does nothing or is an alias of "hostname state" #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:

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions