[#boost-urls-url_base-normalize] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_base.adoc[url_base]::normalize :relfileprefix: ../../../ :mrdocs: Normalize the URL components == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_base.hpp#Lundefined[boost/url/url_base.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:boost/urls/url_base.adoc[url_base]& normalize(); ---- == Description Applies Syntax‐based normalization to all components of the URL. The scheme is normalized to lowercase. [,cpp] ---- assert( url( "HTTP://www.example.com" ).normalize().buffer() == "http://www.example.com" ); ---- The host is normalized to lowercase. Percent‐encoding triplets are normalized to uppercase letters. Percent‐encoded octets that correspond to unreserved characters are decoded. [,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‐encoding triplets in the path are normalized to uppercase letters. Percent‐encoded octets that correspond to unreserved characters are decoded. Redundant path‐segments "." and ".." are removed. [,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‐encoding triplets in the query are normalized to uppercase letters. Percent‐encoded octets that correspond to unreserved characters are decoded. [,cpp] ---- assert( url( "http://www.example.com?a=%62" ).normalize().buffer() == "http://www.example.com?a=b" ); ---- Percent‐encoding triplets in the fragment are normalized to uppercase letters. Percent‐encoded octets that correspond to unreserved characters are decoded. [,cpp] ---- assert( url( "http://www.example.com#%61bc" ).normalize().buffer() == "http://www.example.com#abc" ); ---- Applying normalization to a URL with all components percent‐encoded: [,cpp] ---- assert( url( "HTTP://www.Example.com/%70ath?%71uery#%66rag" ).normalize().buffer() == "http://www.example.com/path?query#frag" ); ---- == Exception Safety Strong guarantee. Calls to allocate may throw. == Specification * https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2[6.2.2 Syntax‐Based Normalization (rfc3986)] == Return Value `*this` == See Also xref:boost/urls/url_base/normalize_scheme.adoc[`normalize_scheme`], xref:boost/urls/url_base/normalize_authority.adoc[`normalize_authority`], xref:boost/urls/url_base/normalize_path.adoc[`normalize_path`], xref:boost/urls/url_base/normalize_query.adoc[`normalize_query`], xref:boost/urls/url_base/normalize_fragment.adoc[`normalize_fragment`] [.small]#Created with https://www.mrdocs.com[MrDocs]#