Skip to main content

normalize_origin

Function normalize_origin 

Source
pub fn normalize_origin(origin: &str) -> String
Expand description

Normalizes an Origin header value for comparison.

  • scheme and host lowercased (both are case-insensitive)
  • default port for the scheme omitted (https://example.com:443 == https://example.com)
  • bracketed IPv6 hosts supported (https://[2001:DB8::1]:443 == https://[2001:db8::1])
  • values without a scheme:// prefix are only case-normalized — they will not match a scheme-normalized allow-list entry (fail-closed)