Skip to main content

Function: isAddressLikeHost()

isAddressLikeHost(host): boolean

Defined in: packages/contracts/src/schemas/federation.ts:55

Whether a URL parser would read this host as an IPv4 address and not as a name.

The rule is the WHATWG URL one ("ends in a number"): the last label is all digits, or 0x followed by hex digits. 10.0.0.1, 127.1 and 10.0.0.0x1 all end that way, and no top-level domain does, so no real hostname is refused by it. It exists beside HOSTNAME_PATTERN because that pattern accepts all three and cannot be changed (see Hostname).

It does not check that the host is otherwise well-formed, and it knows nothing about IPv6, which the pattern already refuses (a colon is not a label character).

Parameters​

host​

string

A hostname, with or without a trailing dot.

Returns​

boolean

true when the host must not be treated as a DNS name.