Function urlutils::normalize_url

source ·
pub fn normalize_url(url: &str) -> Result<String, Error>
Expand description

Make sure that a path string is in fully normalized URL form.

This handles URLs which have unicode characters, spaces, special characters, etc.

It has two basic modes of operation, depending on whether the supplied string starts with a url specifier (scheme://) or not. If it does not have a specifier it is considered a local path, and will be converted into a file:/// url. Non-ascii characters will be encoded using utf-8. If it does have a url specifier, it will be treated as a “hybrid” URL. Basically, a URL that should have URL special characters already escaped (like +?&# etc), but may have unicode characters, etc which would not be valid in a real URL.

Args: url: Either a hybrid URL or a local path Returns: A normalized URL which only includes 7-bit ASCII characters.