url_tincture v0.0.3 UrlTincture
The base module of UrlTincture. This module canonicalizes HTTP(S) urls.
The primary methods provided are canonicalize_url/1
& canonicalize_url/2
Summary
Functions
Canonicalize a url, forcing scheme to be prepended when missing
Canonicalize a url, scheme not prepended when missing by default
Prepend http:// to urls as needed
Validate whether a string is an HTTP(S) url
Detects if URLs are HTTP or HTTPS
Normalizes http scheme/port combinations
Removes the first www. from URLs
Functions
Canonicalize a url, forcing scheme to be prepended when missing.
URLs are:
- Validated.
- Downcased.
- Stripped of www.
- Stripped of fragments.
- http(s) / 80(443) ports are normalized.
Parameters
url
: The URL to canonicalize
Returns:
%UrlTincture.Info{}
on success{:error, "error message"}
on failure
Canonicalize a url, scheme not prepended when missing by default.
See UrlTincture.canonicalize_url/1
for details.
Parameters
url
: The URL to canonicalizeopts
: Options to pass to the canonicalizer (currently onlyforce_http
is supported)
TODO
Replace the hardcoded crypto call with an atom
Prepend http:// to urls as needed.
Parameters
url
- The URL to process
Returns
String
containing the processed URL
Validate whether a string is an HTTP(S) url.
Adapted from github/jonotander/is_url which in turn was adapted from Stack Overflow.
Parameters
url
: The URL to validate
Returns
boolean
Normalizes http scheme/port combinations.
Passes through any unrecognized combinations.
Parameters
scheme
- A string representing the URI parsed schemeport
- An integer representing the URI parsed port
Returns {scheme, port}
(String) port
in the format “:num”