Skip to content

basalt / tenancy/src / normalizeDomain

Function: normalizeDomain() ​

> normalizeDomain(input): string

Defined in: tenancy/src/custom-domains.ts:80

Canonicalize a domain/Host value: lowercase, trim, strip a trailing dot and any port. One function used by registration, verification, lookup AND the Host-header resolver, so a domain always keys the same regardless of how it was typed or presented (Victim.com, victim.com., victim.com:443).

Throws InvalidDomainError (400) for a value that is not a hostname — see tryNormalizeDomain for the grammar. Use tryNormalizeDomain where an invalid value should simply not match (the resolvers do).

Parameters ​

input ​

string

Returns ​

string

Released under the MIT License.