[#boost-urls-url-normalize]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url.adoc[url]::normalize
:relfileprefix: ../../../
:mrdocs:

Normalize the URL components

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url.hpp#Lundefined[boost&sol;url&sol;url&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/url.adoc[url]&
normalize();
----

== Description

Applies Syntax&hyphen;based normalization to all components of the URL&period;

The scheme is normalized to lowercase&period;

[,cpp]
----
assert( url( "HTTP://www.example.com" ).normalize().buffer() == "http://www.example.com" );
----
The host is normalized to lowercase&period; Percent&hyphen;encoding triplets are normalized to uppercase letters&period; Percent&hyphen;encoded octets that correspond to unreserved characters are decoded&period;

[,cpp]
----
assert( url( "http://www.Example.com" ).normalize().buffer() == "http://www.example.com" );
assert( url( "http://www.%65xample.com" ).normalize().buffer() == "http://www.example.com" );
----
Percent&hyphen;encoding triplets in the path are normalized to uppercase letters&period; Percent&hyphen;encoded octets that correspond to unreserved characters are decoded&period; Redundant path&hyphen;segments &quot;&period;&quot; and &quot;&period;&period;&quot; are removed&period;

[,cpp]
----
assert( url( "http://www.example.com/a/b/../c" ).normalize().buffer() == "http://www.example.com/a/c" );
assert( url( "http://www.example.com/a/./b" ).normalize().buffer() == "http://www.example.com/a/b" );
assert( url( "http://www.example.com/%63ss" ).normalize().buffer() == "http://www.example.com/css" );
----
Percent&hyphen;encoding triplets in the query are normalized to uppercase letters&period; Percent&hyphen;encoded octets that correspond to unreserved characters are decoded&period;

[,cpp]
----
assert( url( "http://www.example.com?a=%62" ).normalize().buffer() == "http://www.example.com?a=b" );
----
Percent&hyphen;encoding triplets in the fragment are normalized to uppercase letters&period; Percent&hyphen;encoded octets that correspond to unreserved characters are decoded&period;

[,cpp]
----
assert( url( "http://www.example.com#%61bc" ).normalize().buffer() == "http://www.example.com#abc" );
----
Applying normalization to a URL with all components percent&hyphen;encoded&colon;

[,cpp]
----
assert( url( "HTTP://www.Example.com/%70ath?%71uery#%66rag" ).normalize().buffer() == "http://www.example.com/path?query#frag" );
----
== Exception Safety

Strong guarantee&period; Calls to allocate may throw&period;

== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2[6&period;2&period;2 Syntax&hyphen;Based Normalization (rfc3986)]

== Return Value

`&ast;this`

== See Also

xref:boost/urls/url/normalize_scheme.adoc[`normalize&lowbar;scheme`], xref:boost/urls/url/normalize_authority.adoc[`normalize&lowbar;authority`], xref:boost/urls/url/normalize_path.adoc[`normalize&lowbar;path`], xref:boost/urls/url/normalize_query.adoc[`normalize&lowbar;query`], xref:boost/urls/url/normalize_fragment.adoc[`normalize&lowbar;fragment`]


[.small]#Created with https://www.mrdocs.com[MrDocs]#
