View Source z_url (zotonic_stdlib v1.17.0)

Misc utility URL functions for zotonic

Link to this section Summary

Functions

Given a relative URL and a base URL, calculate the absolute URL.
Decode a "data:" url to its parts. Crashes if the url doesn't have a "data:" protocol.
Find the definitive location of an url, removing url shorteners in the process. Identify as Curl to prevent url shorteners returning HTML pages.
Percent encoding/decoding as defined by RFC 3986 (http://tools.ietf.org/html/rfc3986).
Naive function to remove the protocol from an Url

Link to this section Functions

Link to this function

abs_link(RelativeUrl, BaseUrl)

View Source
-spec abs_link(string() | binary(), string() | binary()) -> binary().
Given a relative URL and a base URL, calculate the absolute URL.
-spec decode_data_url(binary()) ->
                   {ok, Mime :: binary(), Charset :: binary(), Data :: binary()} |
                   {error, unknown_encoding}.
Decode a "data:" url to its parts. Crashes if the url doesn't have a "data:" protocol.
-spec hex_decode(binary()) -> binary().
-spec hex_encode(iodata()) -> binary().
-spec hex_encode_lc(iodata()) -> binary().
Find the definitive location of an url, removing url shorteners in the process. Identify as Curl to prevent url shorteners returning HTML pages.
-spec percent_encode(iodata()) -> binary().
Percent encoding/decoding as defined by RFC 3986 (http://tools.ietf.org/html/rfc3986).
-spec remove_protocol(string()) -> string();
               (binary()) -> binary().
Naive function to remove the protocol from an Url
-spec split_base_host(string() | binary()) -> {binary(), binary()}.
-spec url_decode(string() | binary() | iodata()) -> binary().
-spec url_encode(string() | atom() | float() | integer() | binary() | iodata()) -> binary().
-spec url_path_encode(iodata()) -> binary().