hostname_validator

Function is_valid

Source
pub fn is_valid(hostname: &str) -> bool
Expand description

Validate a hostname according to IETF RFC 1123.

A hostname is valid if the following condition are true:

  • It does not start or end with - or ..
  • It does not contain any characters outside of the alphanumeric range, except for - and ..
  • It is not empty.
  • It is 253 or fewer characters.
  • Its labels (characters separated by .) are not empty.
  • Its labels are 63 or fewer characters.
  • Its lables do not start or end with ‘-’ or ‘.’.