\begin{quote}
\href{http://en.wikipedia.org/wiki/URL_normalization}{\texttt{ Normalize}} a URL \end{quote}
Useful when you need to display, store, deduplicate, sort, compare, etc, URLs.\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17522}{}\doxysection{Install}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17522}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/-\/save normalize-\/url }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17523}{}\doxysection{Usage}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17523}

\begin{DoxyCode}{0}
\DoxyCodeLine{const normalizeUrl = require('normalize-\/url');}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('sindresorhus.com');}
\DoxyCodeLine{//=> 'http://sindresorhus.com'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('HTTP://xn-\/-\/xample-\/hva.com:80/?b=bar\&a=foo');}
\DoxyCodeLine{//=> 'http://êxample.com/?a=foo\&b=bar' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17524}{}\doxysection{API}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17524}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17525}{}\doxysubsection{normalize\+Url(url, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17525}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17526}{}\doxysubsubsection{url}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17526}
Type\+: {\ttfamily string}

URL to normalize.\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17527}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17527}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17528}{}\doxyparagraph{normalize\+Protocol}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17528}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Prepend {\ttfamily http\+:} to the URL if it\textquotesingle{}s protocol-\/relative.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('//sindresorhus.com:80/');}
\DoxyCodeLine{//=> 'http://sindresorhus.com'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('//sindresorhus.com:80/', \{normalizeProtocol: false\});}
\DoxyCodeLine{//=> '//sindresorhus.com' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17529}{}\doxyparagraph{normalize\+Https}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17529}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily false}

Normalize {\ttfamily https\+:} URLs to {\ttfamily http\+:}.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('https://sindresorhus.com:80/');}
\DoxyCodeLine{//=> 'https://sindresorhus.com'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('https://sindresorhus.com:80/', \{normalizeHttps: true\});}
\DoxyCodeLine{//=> 'http://sindresorhus.com' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17530}{}\doxyparagraph{strip\+Fragment}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17530}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Remove the fragment at the end of the URL.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('sindresorhus.com/about.html\#contact');}
\DoxyCodeLine{//=> 'http://sindresorhus.com/about.html'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('sindresorhus.com/about.html\#contact', \{stripFragment: false\});}
\DoxyCodeLine{//=> 'http://sindresorhus.com/about.html\#contact' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17531}{}\doxyparagraph{strip\+WWW}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17531}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Remove {\ttfamily www.} from the URL.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('http://www.sindresorhus.com/about.html\#contact');}
\DoxyCodeLine{//=> 'http://sindresorhus.com/about.html\#contact'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('http://www.sindresorhus.com/about.html\#contact', \{stripWWW: false\});}
\DoxyCodeLine{//=> 'http://www.sindresorhus.com/about.html\#contact' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17532}{}\doxyparagraph{remove\+Query\+Parameters}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17532}
Type\+: {\ttfamily Array$<$Reg\+Exp$\vert$string$>$}~\newline
 Default\+: {\ttfamily \mbox{[}/$^\wedge$utm\+\_\+\textbackslash{}w+/i\mbox{]}}

Remove query parameters that matches any of the provided strings or regexes.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('www.sindresorhus.com?foo=bar\&ref=test\_ref', \{}
\DoxyCodeLine{    removeQueryParameters: ['ref']}
\DoxyCodeLine{\});}
\DoxyCodeLine{//=> 'http://sindresorhus.com/?foo=bar' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17533}{}\doxyparagraph{remove\+Trailing\+Slash}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17533}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Remove trailing slash.

{\bfseries{Note\+:}} Trailing slash is always removed if the URL doesn\textquotesingle{}t have a pathname.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('http://sindresorhus.com/redirect/');}
\DoxyCodeLine{//=> 'http://sindresorhus.com/redirect'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('http://sindresorhus.com/redirect/', \{removeTrailingSlash: false\});}
\DoxyCodeLine{//=> 'http://sindresorhus.com/redirect/'}
\DoxyCodeLine{}
\DoxyCodeLine{normalizeUrl('http://sindresorhus.com/', \{removeTrailingSlash: false\});}
\DoxyCodeLine{//=> 'http://sindresorhus.com' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17534}{}\doxyparagraph{remove\+Directory\+Index}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17534}
Type\+: {\ttfamily boolean} {\ttfamily Array$<$Reg\+Exp$\vert$string$>$}~\newline
 Default\+: {\ttfamily false}

Remove the default directory index file from path that matches any of the provided strings or regexes. When {\ttfamily true}, the regex {\ttfamily /$^\wedge$index\textbackslash{}.\mbox{[}a-\/z\mbox{]}+\$/} is used.


\begin{DoxyCode}{0}
\DoxyCodeLine{normalizeUrl('www.sindresorhus.com/foo/default.php', \{}
\DoxyCodeLine{    removeDirectoryIndex: [/\string^default\(\backslash\).[a-\/z]+\$/]}
\DoxyCodeLine{\});}
\DoxyCodeLine{//=> 'http://sindresorhus.com/foo' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17535}{}\doxysection{Related}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17535}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/compare-urls}{\texttt{ compare-\/urls}} -\/ Compare URLs by first normalizing them
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17536}{}\doxysection{License}\label{md_sfcode_node_modules_mini_css_extract_plugin_node_modules_normalize_url_readme_autotoc_md17536}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 