This feature is experimental. Please share your experiences so we know what to keep or change.
Returns a normalized version of the given URL string.
Two URLs that point to the same resource should normalize to the same string.
The main purpose of this function is to normalize two URLs for string comparison:
up.util.normalizeURL('http://current-host/path') === up.util.normalizeURL('/path') // => true
By default the hostname is only included if it points to a different origin:
up.util.normalizeURL('http://current-host/path') // => '/path'
up.util.normalizeURL('http://other-host/path') // => 'http://other-host/path'
Relative paths are normalized to absolute paths:
up.util.normalizeURL('index.html') // => '/path/index.html'
You may pass options to exclude URL components from the normalized string:
up.util.normalizeURL('/foo?query=bar', { query: false }) => '/foo'
up.util.normalizeURL('/bar#hash', { hash: false }) => '/bar'
http
and https
schemes are supported.URL to normalize
Whether to include protocol, hostname and port in the normalized URL.
When set to 'cross-domain'
(the default), the host is only included if it differ's from the page's hostname.
The port is omitted if the port is the standard port for the given protocol, e.g. :443
for https://
.
Whether to include an #hash
anchor in the normalized URL.
Whether to include a ?query
string in the normalized URL.
Whether to include a trailing slash from the pathname.
The normalized URL.