Expand description
Types for domain names, either as a reference identifier or a presented identifier, with support for internationalized domain names
Rules for domain names as implemented here (based on a mix of RFC 952, RFC 1034, RFC 1123, RFC 2181, the WHATWG URL specification, browser implementations, and browser bugs) are:
- A domain name has a maximum total length (including ’.’s) of 253 characters/octets/bytes (RFC 1034 section 3.1, Unicode TR46 section 4)
- Domain name labels (the things seperated by ‘.’) have a maximum length of 63 characters/octets/bytes each, not including the separators (RFC 1034 section 3.5, RFC 1123 section 2.1, RFC 2181 section 11)
- A domain name label must consist of only ASCII letters (
'a'..='z' | 'A'..='Z'), digits ('0'..='9'), and hyphens ('-'). A label can not start or end with a hyphen. (RFC 952 section B, RFC 1034 section 3.5, RFC 1123 section 2.1) - Additionally, a label can also contain underscores (
'_') in the same places as letters for compatibility reasons. (Additional discussion around underscores in a Firefox bug, implementations in Chromium and Firefox) - A wildcard (
"*") can only comprise the entire left-most label of a domain name and matches exactly one label. ([RFC 2818] section 3.1, RFC 6125 section 6.4.3; i.e."*.example.com"is valid and matches"foo.example.com"and"bar.example.com"but does not match"foo.bar.example.com"or"example.com", and all of the following are invalid:"*.*.example.com","foo.*.example.com","fo*.example.com","*oo.example.com","f*o.example.com") - No special treatment is given to wildcards on top-level domains (e.g.
"*.com"), or on other public suffixes (e.g. “*.co.uk” or"*.pvt.k12.ma.us"), which allows some potentially invalid wildcard domains; full wildcard domains ("*") are not allowed - Percent-encoded domain names (e.g.
"e%78ample.com") are not supported, and'%'is treated as an invalid character
Structs§
- Domain
- A domain name split into individual labels (not including the root label).
- Label
- A domain name label, stored in lowercase in its ASCII-encoded form
Enums§
- Parse
Error - An error encountered while parsing a domain name