URL normalization.
Norma parses a URL string and rewrites it into a canonical form,
defaulting the scheme to http and applying the transformations
requested through the options map.
Two entry points are provided:
normalize_if_valid/2— returns{:ok, url}or{:error, reason}.normalize/2— returns the normalized URL, or the input unchanged when it isn't a URL.
See normalize_if_valid/2 for the list of supported options.
Summary
Functions
Similar to normalize_if_valid/2, but will return the given string unchanged
if it's not an URL.
Normalize URL according to the options given.
Defaults scheme to http.
Functions
Similar to normalize_if_valid/2, but will return the given string unchanged
if it's not an URL.
Examples
iex> Norma.normalize!("//www.mazing.studio", %{remove_www: true})
"http://mazing.studio"
Normalize URL according to the options given.
Defaults scheme to http.
Options
remove_fragmentforce_root_pathadd_trailing_slashremove_wwwdowncase_host
Check the README for the full examples.
Examples
iex> Norma.normalize("//www.mazing.studio", %{remove_www: true})
{:ok, "http://mazing.studio"}