\href{https://travis-ci.org/defunctzombie/node-url}{\texttt{ }}

This module has utilities for URL resolution and parsing meant to have feature parity with node.\+js core \href{http://nodejs.org/api/url.html}{\texttt{ url}} module.


\begin{DoxyCode}{0}
\DoxyCodeLine{var url = require('url'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_url_README_autotoc_md31607}{}\doxysection{api}\label{md_sfcode_node_modules_url_README_autotoc_md31607}
Parsed URL objects have some or all of the following fields, depending on whether or not they exist in the URL string. Any parts that are not in the URL string will not be in the parsed object. Examples are shown for the URL

`\textquotesingle{}\href{http://user:pass@host.com:8080/p/a/t/h?query=string\#hash&rsquo;}{\texttt{ http\+://user\+:pass@host.\+com\+:8080/p/a/t/h?query=string\#hash'}}\`{}


\begin{DoxyItemize}
\item {\ttfamily href}\+: The full URL that was originally parsed. Both the protocol and host are lowercased.

Example\+: `\textquotesingle{}\href{http://user:pass@host.com:8080/p/a/t/h?query=string\#hash&rsquo;}{\texttt{ http\+://user\+:pass@host.\+com\+:8080/p/a/t/h?query=string\#hash'}}\`{}
\item {\ttfamily protocol}\+: The request protocol, lowercased.

Example\+: `\textquotesingle{}\href{http:&rsquo;}{\texttt{ http\+:'}}\`{}
\item {\ttfamily host}\+: The full lowercased host portion of the URL, including port information.

Example\+: `\textquotesingle{}host.\+com\+:8080'\`{}
\item {\ttfamily auth}\+: The authentication information portion of a URL.

Example\+: `\textquotesingle{}user\+:pass'\`{}
\item {\ttfamily hostname}\+: Just the lowercased hostname portion of the host.

Example\+: `\textquotesingle{}host.\+com'\`{}
\item {\ttfamily port}\+: The port number portion of the host.

Example\+: `\textquotesingle{}8080'\`{}
\item {\ttfamily pathname}\+: The path section of the URL, that comes after the host and before the query, including the initial slash if present.

Example\+: `'/p/a/t/h\textquotesingle{}\`{}
\item {\ttfamily search}\+: The \textquotesingle{}query string\textquotesingle{} portion of the URL, including the leading question mark.

Example\+: `'?query=string\textquotesingle{}\`{}
\item {\ttfamily path}\+: Concatenation of {\ttfamily pathname} and {\ttfamily search}.

Example\+: `'/p/a/t/h?query=string\textquotesingle{}\`{}
\item {\ttfamily query}\+: Either the \textquotesingle{}params\textquotesingle{} portion of the query string, or a querystring-\/parsed object.

Example\+: `\textquotesingle{}query=string'{\ttfamily or}\{\textquotesingle{}query\textquotesingle{}\+:\textquotesingle{}string\textquotesingle{}\}\`{}
\item {\ttfamily hash}\+: The \textquotesingle{}fragment\textquotesingle{} portion of the URL including the pound-\/sign.

Example\+: `'\#hash\textquotesingle{}\`{}
\end{DoxyItemize}

The following methods are provided by the URL module\+:\hypertarget{md_sfcode_node_modules_url_README_autotoc_md31608}{}\doxysubsection{url.\+parse(url\+Str, \mbox{[}parse\+Query\+String\mbox{]}, \mbox{[}slashes\+Denote\+Host\mbox{]})}\label{md_sfcode_node_modules_url_README_autotoc_md31608}
Take a URL string, and return an object.

Pass {\ttfamily true} as the second argument to also parse the query string using the {\ttfamily querystring} module. Defaults to {\ttfamily false}.

Pass {\ttfamily true} as the third argument to treat {\ttfamily //foo/bar} as `\{ host\+: \textquotesingle{}foo', pathname\+: \textquotesingle{}/bar\textquotesingle{} \}{\ttfamily rather than }\{ pathname\+: \textquotesingle{}//foo/bar\textquotesingle{} \}{\ttfamily . Defaults to}false\`{}.\hypertarget{md_sfcode_node_modules_url_README_autotoc_md31609}{}\doxysubsection{url.\+format(url\+Obj)}\label{md_sfcode_node_modules_url_README_autotoc_md31609}
Take a parsed URL object, and return a formatted URL string.


\begin{DoxyItemize}
\item {\ttfamily href} will be ignored.
\item {\ttfamily protocol} is treated the same with or without the trailing {\ttfamily \+:} (colon).
\begin{DoxyItemize}
\item The protocols {\ttfamily http}, {\ttfamily https}, {\ttfamily ftp}, {\ttfamily gopher}, {\ttfamily file} will be postfixed with {\ttfamily \+://} (colon-\/slash-\/slash).
\item All other protocols {\ttfamily mailto}, {\ttfamily xmpp}, {\ttfamily aim}, {\ttfamily sftp}, {\ttfamily foo}, etc will be postfixed with {\ttfamily \+:} (colon)
\end{DoxyItemize}
\item {\ttfamily auth} will be used if present.
\item {\ttfamily hostname} will only be used if {\ttfamily host} is absent.
\item {\ttfamily port} will only be used if {\ttfamily host} is absent.
\item {\ttfamily host} will be used in place of {\ttfamily hostname} and {\ttfamily port}
\item {\ttfamily pathname} is treated the same with or without the leading {\ttfamily /} (slash)
\item {\ttfamily search} will be used in place of {\ttfamily query}
\item {\ttfamily query} (object; see {\ttfamily querystring}) will only be used if {\ttfamily search} is absent.
\item {\ttfamily search} is treated the same with or without the leading {\ttfamily ?} (question mark)
\item {\ttfamily hash} is treated the same with or without the leading {\ttfamily \#} (pound sign, anchor)
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_url_README_autotoc_md31610}{}\doxysubsection{url.\+resolve(from, to)}\label{md_sfcode_node_modules_url_README_autotoc_md31610}
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. Examples\+: \begin{DoxyVerb}url.resolve('/one/two/three', 'four')         // '/one/two/four'
url.resolve('http://example.com/', '/one')    // 'http://example.com/one'
url.resolve('http://example.com/one', '/two') // 'http://example.com/two'
\end{DoxyVerb}
 