normalize_url

Function normalize_url 

Source
pub fn normalize_url(url: &str) -> Result<String, NormalizeError>
Expand description

Normalizes URLs and file paths into valid IRI format with consistent scheme handling.

Adds file: scheme to paths, resolves relative paths, handles ~/ expansion, and properly encodes spaces and special characters.

ยงExamples

assert_eq!(normalize_url("https://example.org")?, "https://example.org/");
assert!(normalize_url("path with spaces.txt")?.starts_with("file:"));
assert!(normalize_url("~/document.txt")?.ends_with("/document.txt"));