pub fn host<S: Spec>(s: &str) -> Result<(), Error>Expand description
Validates IRI host.
ยงExamples
use iri_string::{spec::UriSpec, validate::host};
assert!(host::<UriSpec>("example.com").is_ok());
assert!(host::<UriSpec>("subdomain.example.com").is_ok());
assert!(host::<UriSpec>("no-period").is_ok());
// Though strongly discouraged, this percent-encoded reg-name with
// non-UTF-8 bytes is considered syntactically valid.
assert!(host::<UriSpec>("non-%99-utf-8").is_ok());
// Empty host is valid. Remember `file:///` has empty authority (and empty host).
assert!(host::<UriSpec>("").is_ok());
assert!(host::<UriSpec>("127.0.0.1").is_ok());
assert!(host::<UriSpec>("[::1]").is_ok());
assert!(host::<UriSpec>("[::127.0.0.1]").is_ok());
// Syntax for future versions of IP addresses.
assert!(host::<UriSpec>("[v89ab.1+2,3(4)5&6]").is_ok());
// `port` is not a part of the host.
assert!(host::<UriSpec>("host:8080").is_err());
// `userinfo` is not a part of the host.
assert!(host::<UriSpec>("user:password@host").is_err());