Skip to main content

normalize_resource_path

Function normalize_resource_path 

Source
pub fn normalize_resource_path(p: &str) -> Result<String, String>
Expand description

Validate p against the logical path model (SPEC §5.7.3) and return its comparison form: at most one trailing / trimmed, except for the root path / itself. Returns Err when p is not a valid logical path:

  • must begin with / (/ is the only separator)
  • no NUL byte, no backslash (rejected, never translated)
  • no . or .. segment (rejected outright, never resolved)
  • no empty interior segment (/a//b is invalid; / is valid)

% is an ordinary literal byte: the path model has no percent-encoding.