This module provides a couple of simple utilities to deal with
the generation and parsing of uniform resource identifiers (URIs).
The predicates make_query/4, make_spec/4 and make_uri/4 allow
constructing and deconstructing queries, specs and URIs. The
predicates work bidirectional without loss of data.
?- make_query(X, Y, Z, 'a%3Db=c%26d&e').
X = 'a=b',
Y = 'c&d',
Z = e
The predicates make_query/4, make_spec/4 and make_uri/4 do a minimal encoding. For the parameter name and the parameter value the characters '#%=&\' will be encoded. For the hash the characters '%\' will be encoded. For the spec the characters '?#%\' will be encoded. If used in the other direction the predicates will perform decoding of the corresponding components.
An URI is relative when it neither contains a scheme nor an
authority, and if the path is relative. The predicate
is_relative_uri/1 checks whether an URI is relative. The predicate
follow_uri/3 can be used to resolve and relativize URIs. Contrary
to the Java URL class, it is agnostic to the scheme of the URIs
and will allow any scheme. In these predicates the path component
is handled by the corresponding routines from system/file.
X = '../tip/tap?fix#fox'
The predicate canonical_uri/2 can be used to canonize URIs. For the file protocol the path component is handled by the corresponding routine from the module file. For other protocols the routine uses puny code from the module domain and accesses the server for redirects.
The predicate uri_encode/2 can be used to encode and decode URIs.
The predicate uri_encode/2 will percent encode characters above
0x7F. As a result the URI will only contain ASCII. If used in the
other direction the predicate will first decode and then minimal
The following URI predicates are provided: