Skip to main content

https_origin

Function https_origin 

Source
pub fn https_origin(url: &str) -> Option<String>
Expand description

The normalized https: origin of an absolute URL: scheme://host:port with the default port made explicit.

None — meaning “no origin can be compared” — for anything that is not an absolute https: URL this crate is willing to reason about. That includes an http: URL (no TLS anchor, and the TLS name IS the trust model of §8.4.4), a URL carrying userinfo, and a host with a percent-escape. All three are refusals rather than best-effort parses: this function’s answers gate a fetch, so an ambiguous URL must fail closed rather than be normalized into whatever the parser guessed.

No URL crate is introduced, and none is needed: the grammar an APH origin comparison reads is the authority component of an absolute https: URL and nothing more. Every shape outside that grammar is None rather than a partial parse, which is why the narrowness is safe here and would not be in a general-purpose URL type.