Function iri_string::resolve::try_resolve_normalize_whatwg
source · [−]pub fn try_resolve_normalize_whatwg<S: Spec>(
reference: impl AsRef<RiReferenceStr<S>>,
base: impl AsRef<RiAbsoluteStr<S>>
) -> Result<RiString<S>, TaskError<Infallible>>Expand description
Resolves and normalizes the IRI reference.
It is recommended to use methods such as
RiReferenceStr::try_resolve_normalize_whatwg_against() and
RiRelativeStr::try_resolve_normalize_whatwg_against(), rather than this
freestanding function.
If you are going to resolve multiple references against the common base,
consider using FixedBaseResolver.
Enabled by alloc or std feature.
Failures
This fails if memory allocation failed.
Examples
use iri_string::resolve::{try_resolve_normalize_whatwg, FixedBaseResolver};
use iri_string::task::ProcessAndWrite;
use iri_string::types::{IriAbsoluteStr, IriReferenceStr};
let base = IriAbsoluteStr::new("scheme:/path")?;
let reference = IriReferenceStr::new("..//not-a-host")?;
// Resolve and normalize `reference` against `base`.
let resolved = try_resolve_normalize_whatwg(reference, base)?;
assert_eq!(resolved, "scheme:/.//not-a-host");