From b439d19d38479d6264d906dd926a168c9c514da3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Dimitrov?= A URI is an identifier consisting of a sequence of characters matching the syntax
rule named URI in RFC 3986. The generic URI syntax consists of a hierarchical sequence of components referred
- to as the scheme, authority, path, query, and fragment:
+ to as the scheme, authority, path, query, and fragment:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] hier-part = "//" authority path-abempty / path-absolute @@ -51,35 +52,26 @@ unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
The interpretation of a URI depends only on the characters used and not on how those characters are represented in a network protocol.
-The functions implemented by this module covers the following use cases: +
The functions implemented by this module covers the following use cases:
There are four different encodings present during the handling of URIs: +
There are four different encodings present during the handling of URIs:
Unless otherwise specified the return value type and encoding are the same as the input
type and encoding. That is, binary input returns binary output, list input returns a list
output but mixed input returns list output. Input and output encodings are the same except
@@ -113,31 +105,34 @@
Composes an urlencoded Composes a form-urlencoded If an argument is invalid, a Example: Creates an RFC 3986 compliant If an argument is invalid, a Same as Example:
-1> uri_string:compose_query(...).
-
+1> uri_string:compose_query([{"foo bar","1"},{"city","örebro"}]).
+
+
-1> uri_string:create_uri_reference(...,...).
-
+1> uri_string:compose_query([{"foo bar","1"},{"city","örebro"}],
+2> [{separator, semicolon}]).
+"foo+bar=1;city=%C3%B6rebro"
+
Dissects an urlencoded
If an argument is invalid, a
Example:
-1> uri_string:dissect_query(...). -- - - -
Normalizes an RFC 3986 compliant
If an argument is invalid, a
Example:
--1> uri_string:normalize("http://example.org/one/two/../../one"). -"http://example.org/one" -+1> uri_string:dissect_query("foo+bar=1;city=%C3%B6rebro"). +[{"foo bar","1"},{"city","örebro"}] +
Returns a
If parsing fails, a
If parsing fails, an error tuple is returned.
Example:
1> uri_string:parse("foo://user@example.com:8042/over/there?name=ferret#nose"). #{fragment => "nose",host => "example.com", path => "/over/there",port => 8042,query => "name=ferret", scheme => foo,userinfo => "user"} -2>+
Returns an RFC 3986 compliant
If the
If the
Example:
1> URIMap = #{fragment => "nose", host => "example.com", path => "/over/there", -port => 8042, query => "name=ferret", scheme => foo, userinfo => "user"}. +port => 8042, query => "name=ferret", scheme => "foo", userinfo => "user"}. #{fragment => "top",host => "example.com", path => "/over/there",port => 8042,query => "?name=ferret", scheme => foo,userinfo => "user"} -2> uri_string:recompose(URIMap, []). +2> uri_string:recompose(URIMap). "foo://example.com:8042/over/there?name=ferret#nose"
Resolves an RFC 3986 compliant
If an argument is invalid, a
Example:
--1> uri_string:resolve_uri_reference(...,...). --
Transcodes an RFC 3986 compliant
If an argument is invalid, a
If an argument is invalid, an error tuple is returned.
Example:
-1> uri_string:transcode(<<"foo://f%20oo">>, [{in_encoding, utf8}, -{out_encoding, utf16}]). -<<0,102,0,111,0,111,0,58,0,47,0,47,0,102,0,37,0,48,0,48,0,37,0,50,0,48,0, - 111,0,111>> -+1> >,]]> +2> [{in_encoding, utf32},{out_encoding, utf8}]). +>]]> +