Skip to main content

strip_base_path

Function strip_base_path 

Source
pub fn strip_base_path<'a>(path: &'a str, base_path: &str) -> Option<&'a str>
Expand description

Try to strip base_path from a URL path on a segment boundary.

Returns Some(remainder) if path is exactly base_path (with or without trailing slash) or starts with base_path. Returns None otherwise so the caller can decide between redirect and 404.

The remainder never has a leading /.