\href{https://npmjs.org/package/parseurl}{\texttt{ }} \href{https://npmjs.org/package/parseurl}{\texttt{ }} \href{https://nodejs.org/en/download}{\texttt{ }} \href{https://travis-ci.org/pillarjs/parseurl}{\texttt{ }} \href{https://coveralls.io/r/pillarjs/parseurl?branch=master}{\texttt{ }}

Parse a URL with memoization.\hypertarget{md_sfcode_node_modules_parseurl_README_autotoc_md20253}{}\doxysection{Install}\label{md_sfcode_node_modules_parseurl_README_autotoc_md20253}
This is a \href{https://nodejs.org/en/}{\texttt{ Node.\+js}} module available through the \href{https://www.npmjs.com/}{\texttt{ npm registry}}. Installation is done using the \href{https://docs.npmjs.com/getting-started/installing-npm-packages-locally}{\texttt{ {\ttfamily npm install} command}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install parseurl }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_parseurl_README_autotoc_md20254}{}\doxysection{API}\label{md_sfcode_node_modules_parseurl_README_autotoc_md20254}

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

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_parseurl_README_autotoc_md20255}{}\doxysubsection{parseurl(req)}\label{md_sfcode_node_modules_parseurl_README_autotoc_md20255}
Parse the URL of the given request object (looks at the {\ttfamily req.\+url} property) and return the result. The result is the same as {\ttfamily url.\+parse} in Node.\+js core. Calling this function multiple times on the same {\ttfamily req} where {\ttfamily req.\+url} does not change will return a cached parsed object, rather than parsing again.\hypertarget{md_sfcode_node_modules_parseurl_README_autotoc_md20256}{}\doxysubsection{parseurl.\+original(req)}\label{md_sfcode_node_modules_parseurl_README_autotoc_md20256}
Parse the original URL of the given request object and return the result. This works by trying to parse {\ttfamily req.\+original\+Url} if it is a string, otherwise parses {\ttfamily req.\+url}. The result is the same as {\ttfamily url.\+parse} in Node.\+js core. Calling this function multiple times on the same {\ttfamily req} where {\ttfamily req.\+original\+Url} does not change will return a cached parsed object, rather than parsing again.\hypertarget{md_sfcode_node_modules_parseurl_README_autotoc_md20257}{}\doxysection{Benchmark}\label{md_sfcode_node_modules_parseurl_README_autotoc_md20257}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm run-\/script bench}
\DoxyCodeLine{}
\DoxyCodeLine{> parseurl@1.3.3 bench nodejs-\/parseurl}
\DoxyCodeLine{> node benchmark/index.js}
\DoxyCodeLine{}
\DoxyCodeLine{  http\_parser@2.8.0}
\DoxyCodeLine{  node@10.6.0}
\DoxyCodeLine{  v8@6.7.288.46-\/node.13}
\DoxyCodeLine{  uv@1.21.0}
\DoxyCodeLine{  zlib@1.2.11}
\DoxyCodeLine{  ares@1.14.0}
\DoxyCodeLine{  modules@64}
\DoxyCodeLine{  nghttp2@1.32.0}
\DoxyCodeLine{  napi@3}
\DoxyCodeLine{  openssl@1.1.0h}
\DoxyCodeLine{  icu@61.1}
\DoxyCodeLine{  unicode@10.0}
\DoxyCodeLine{  cldr@33.0}
\DoxyCodeLine{  tz@2018c}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/fullurl.js}
\DoxyCodeLine{}
\DoxyCodeLine{  Parsing URL "{}http://localhost:8888/foo/bar?user=tj\&pet=fluffy"{}}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  fasturl            x 2,207,842 ops/sec ±3.76\% (184 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ legacy x   507,180 ops/sec ±0.82\% (191 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ whatwg x   290,044 ops/sec ±1.96\% (189 runs sampled)}
\DoxyCodeLine{  parseurl           x   488,907 ops/sec ±2.13\% (192 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/pathquery.js}
\DoxyCodeLine{}
\DoxyCodeLine{  Parsing URL "{}/foo/bar?user=tj\&pet=fluffy"{}}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  fasturl            x 3,812,564 ops/sec ±3.15\% (188 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ legacy x 2,651,631 ops/sec ±1.68\% (189 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ whatwg x   161,837 ops/sec ±2.26\% (189 runs sampled)}
\DoxyCodeLine{  parseurl           x 4,166,338 ops/sec ±2.23\% (184 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/samerequest.js}
\DoxyCodeLine{}
\DoxyCodeLine{  Parsing URL "{}/foo/bar?user=tj\&pet=fluffy"{} on same request object}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  fasturl            x  3,821,651 ops/sec ±2.42\% (185 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ legacy x  2,651,162 ops/sec ±1.90\% (187 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ whatwg x    175,166 ops/sec ±1.44\% (188 runs sampled)}
\DoxyCodeLine{  parseurl           x 14,912,606 ops/sec ±3.59\% (183 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/simplepath.js}
\DoxyCodeLine{}
\DoxyCodeLine{  Parsing URL "{}/foo/bar"{}}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  fasturl            x 12,421,765 ops/sec ±2.04\% (191 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ legacy x  7,546,036 ops/sec ±1.41\% (188 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ whatwg x    198,843 ops/sec ±1.83\% (189 runs sampled)}
\DoxyCodeLine{  parseurl           x 24,244,006 ops/sec ±0.51\% (194 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/slash.js}
\DoxyCodeLine{}
\DoxyCodeLine{  Parsing URL "{}/"{}}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  fasturl            x 17,159,456 ops/sec ±3.25\% (188 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ legacy x 11,635,097 ops/sec ±3.79\% (184 runs sampled)}
\DoxyCodeLine{  nativeurl -\/ whatwg x    240,693 ops/sec ±0.83\% (189 runs sampled)}
\DoxyCodeLine{  parseurl           x 42,279,067 ops/sec ±0.55\% (190 runs sampled) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_parseurl_README_autotoc_md20258}{}\doxysection{License}\label{md_sfcode_node_modules_parseurl_README_autotoc_md20258}
\mbox{[}MIT\mbox{]}(LICENSE) 