diff options
author | Péter Dimitrov <[email protected]> | 2018-02-07 16:08:32 +0100 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2018-02-08 16:26:54 +0100 |
commit | c69bbc7ce1af2dc295fc17fcb31485e2d4caafa7 (patch) | |
tree | a9a4a8e3ee569f87dbf9e04053cbd1c2af42d451 /lib/stdlib/doc/src/uri_string.xml | |
parent | 3cb3d5c1927e6235b0e51ba7ca31e2a3458fba01 (diff) | |
download | otp-c69bbc7ce1af2dc295fc17fcb31485e2d4caafa7.tar.gz otp-c69bbc7ce1af2dc295fc17fcb31485e2d4caafa7.tar.bz2 otp-c69bbc7ce1af2dc295fc17fcb31485e2d4caafa7.zip |
stdlib: Improve URI normalization in uri_string
- normalize/1 accepts uri_map() as input type and can return
error() if URI parsing fails.
- Added normalize/2 that can return a normalized uri_map().
Change-Id: Icdd2e60c15019d3eec2e7bc994cae03066a79194
Diffstat (limited to 'lib/stdlib/doc/src/uri_string.xml')
-rw-r--r-- | lib/stdlib/doc/src/uri_string.xml | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lib/stdlib/doc/src/uri_string.xml b/lib/stdlib/doc/src/uri_string.xml index 21f470e763..6b52ffdd4d 100644 --- a/lib/stdlib/doc/src/uri_string.xml +++ b/lib/stdlib/doc/src/uri_string.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2017</year><year>2017</year> + <year>2017</year><year>2018</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -24,7 +24,7 @@ <title>uri_string</title> <prepared>Péter Dimitrov</prepared> <docno>1</docno> - <date>2017-10-24</date> + <date>2018-02-07</date> <rev>A</rev> </header> <module>uri_string</module> @@ -70,7 +70,8 @@ <seealso marker="#transcode/2"><c>transcode/2</c></seealso> </item> <item>Transforming URIs into a normalized form<br></br> - <seealso marker="#normalize/1"><c>normalize/1</c></seealso> + <seealso marker="#normalize/1"><c>normalize/1</c></seealso><br></br> + <seealso marker="#normalize/2"><c>normalize/2</c></seealso> </item> <item>Composing form-urlencoded query strings from a list of key-value pairs<br></br> <seealso marker="#compose_query/1"><c>compose_query/1</c></seealso><br></br> @@ -233,7 +234,7 @@ <name name="normalize" arity="1"/> <fsummary>Syntax-based normalization.</fsummary> <desc> - <p>Transforms <c><anno>URIString</anno></c> into a normalized form + <p>Transforms an <c><anno>URI</anno></c> into a normalized form using Syntax-Based Normalization as defined by <url href="https://www.ietf.org/rfc/rfc3986.txt">RFC 3986</url>.</p> <p>This function implements case normalization, percent-encoding @@ -247,6 +248,33 @@ <![CDATA[<<"mid/6">>]]> 3> uri_string:normalize("http://localhost:80"). "https://localhost/" +4> <input>uri_string:normalize(#{scheme => "http",port => 80,path => "/a/b/c/./../../g",</input> +4> host => "localhost-örebro"}). +"http://localhost-%C3%B6rebro/a/g" + </pre> + </desc> + </func> + + <func> + <name name="normalize" arity="2"/> + <fsummary>Syntax-based normalization.</fsummary> + <desc> + <p>Same as <c>normalize/1</c> but with an additional + <c><anno>Options</anno></c> parameter, that controls if the normalized URI + shall be returned as an uri_map(). + There is one supported option: <c>return_map</c>. + </p> + <p><em>Example:</em></p> + <pre> +1> <input>uri_string:normalize("/a/b/c/./../../g", [return_map]).</input> +#{path => "/a/g"} +2> <![CDATA[uri_string:normalize(<<"mid/content=5/../6">>, [return_map]).]]> +<![CDATA[#{path => <<"mid/6">>}]]> +3> uri_string:normalize("http://localhost:80", [return_map]). +#{scheme => "http",path => "/",host => "localhost"} +4> <input>uri_string:normalize(#{scheme => "http",port => 80,path => "/a/b/c/./../../g",</input> +4> host => "localhost-örebro"}, [return_map]). +#{scheme => "http",path => "/a/g",host => "localhost-örebro"} </pre> </desc> </func> |