\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_humanize_url_node_modules_normalize_url_readme_autotoc_md12529}{}\doxysection{Install}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12529}

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

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

\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_humanize_url_node_modules_normalize_url_readme_autotoc_md12531}{}\doxysection{API}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12531}
\hypertarget{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12532}{}\doxysubsection{normalize\+Url(url, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12532}
\hypertarget{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12533}{}\doxysubsubsection{url}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12533}
Type\+: {\ttfamily string}

URL to normalize.\hypertarget{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12534}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12534}
\hypertarget{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12535}{}\doxyparagraph{normalize\+Protocol}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12535}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12536}{}\doxyparagraph{normalize\+Https}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12536}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12537}{}\doxyparagraph{strip\+Fragment}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12537}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12538}{}\doxyparagraph{strip\+WWW}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12538}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12539}{}\doxyparagraph{remove\+Query\+Parameters}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12539}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12540}{}\doxyparagraph{remove\+Trailing\+Slash}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12540}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12541}{}\doxyparagraph{remove\+Directory\+Index}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12541}
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_humanize_url_node_modules_normalize_url_readme_autotoc_md12542}{}\doxysection{Related}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12542}

\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_humanize_url_node_modules_normalize_url_readme_autotoc_md12543}{}\doxysection{License}\label{md_sfcode_node_modules_humanize_url_node_modules_normalize_url_readme_autotoc_md12543}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 