Skip to main content

extract_authority

Function extract_authority 

Source
pub fn extract_authority(host: &str) -> String
Expand description

Extract and normalize the @authority component from a Host header.

Performs RFC 9421 canonicalization:

  • Converts to lowercase
  • Removes default ports (80 for HTTP, 443 for HTTPS)

ยงExample

use herolib_crypt::httpsig::extract_authority;

assert_eq!(extract_authority("api.example.com"), "api.example.com");
assert_eq!(extract_authority("API.EXAMPLE.COM"), "api.example.com");
assert_eq!(extract_authority("api.example.com:443"), "api.example.com");
assert_eq!(extract_authority("api.example.com:8080"), "api.example.com:8080");