Skip to main content

normalize_domain

Function normalize_domain 

Source
pub fn normalize_domain(domain: &str) -> Result<String>
Expand description

Normalizes and validates a domain name.

This function:

  • Removes http:// and https:// prefixes
  • Removes www. prefix
  • Removes trailing slashes and paths
  • Converts to lowercase
  • Converts internationalized domain names (IDN) to Punycode (ASCII)
  • Validates format (must contain dots, only alphanumeric/hyphens/dots)
  • Does NOT perform SSRF checks. For network operations, resolve and validate via crate::net::resolve_public_host (or validate_public_host), which returns the vetted SocketAddrs to connect to — closing the resolve-then-connect (DNS-rebinding) window.