Parses the scheme-specific part of a tel URL as defined
in RFC 3966.
When the optional ex_phone_number dependency is available the
number is formatted in international form, with a phone-context
parameter that is itself a number prepended first. The territory
used for numbers without a country code comes from the current
localize locale, then the current gettext locale, then "US".
Numbers that ex_phone_number cannot parse are kept as written.
The primary API is parse/1, which URL.new/1 calls for any URL
with the tel scheme.
Summary
Types
Functions
Parses the path of a tel URI into a t/0 struct.
Arguments
uriis aURI.t/0whose:schemeis"tel".
Returns
{:ok, t:t/0}with the formatted (or, if it cannot be parsed, unformatted) telephone number in:teland any parameters in:params, or{:error, {URL.Parser.ParseError, reason}}if the path is not a valid telephone subscriber string, including an empty path.
Examples
iex> tel = URI.parse "tel:+61-0407-555-987"
iex> URL.Tel.parse(tel)
{:ok, %URL.Tel{tel: "+61 407 555 987", params: %{}}}
iex> tel = URI.parse "tel:0407-555-987;phone-context=+61"
iex> URL.Tel.parse(tel)
{:ok, %URL.Tel{tel: "+61 407 555 987", params: %{"phone-context" => "+61"}}}
iex> {:error, {URL.Parser.ParseError, _reason}} = URL.Tel.parse(URI.parse("tel:abc"))