boost::urls::static_url::normalize

Normalize the URL components

Synopsis

Declared in <boost/url/static_url.hpp>

static_url&
normalize();

Description

Applies Syntax‐based normalization to all components of the URL.

The scheme is normalized to lowercase.

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.

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.

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.

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.

assert( url( "http://www.example.com#%61bc" ).normalize().buffer() == "http://www.example.com#abc" );

Applying normalization to a URL with all components percent‐encoded:

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.

Return Value

*this