pub fn is_domain_name(host: &str) -> boolExpand description
Check if the given host is a domain name (not an IP address or special value)
Returns true for domain names like example.com, api.backend.internal, localhost
Returns false for IP addresses, unix sockets, variables, or upstream names without dots
ยงExamples
use nginx_lint_plugin::helpers::is_domain_name;
// Domain names
assert!(is_domain_name("example.com"));
assert!(is_domain_name("api.example.com"));
assert!(is_domain_name("localhost"));
assert!(is_domain_name("backend.internal"));
assert!(is_domain_name("example.com:8080"));
// Not domain names
assert!(!is_domain_name("127.0.0.1"));
assert!(!is_domain_name("127.0.0.1:8080"));
assert!(!is_domain_name("[::1]"));
assert!(!is_domain_name("[::1]:8080"));
assert!(!is_domain_name("$backend"));
assert!(!is_domain_name("unix:/var/run/app.sock"));
assert!(!is_domain_name("backend")); // upstream name without dots