3 [![NPM Version][npm-image]][npm-url]
4 [![NPM Downloads][downloads-image]][downloads-url]
5 [![Node.js Version][node-version-image]][node-version-url]
6 [![Build Status][travis-image]][travis-url]
7 [![Test Coverage][coveralls-image]][coveralls-url]
9 Parse a URL with memoization.
14 $ npm install parseurl
20 var parseurl = require('parseurl')
25 Parse the URL of the given request object (looks at the `req.url` property)
26 and return the result. The result is the same as `url.parse` in Node.js core.
27 Calling this function multiple times on the same `req` where `req.url` does
28 not change will return a cached parsed object, rather than parsing again.
30 ### parseurl.original(req)
32 Parse the original URL of the given request object and return the result.
33 This works by trying to parse `req.originalUrl` if it is a string, otherwise
34 parses `req.url`. The result is the same as `url.parse` in Node.js core.
35 Calling this function multiple times on the same `req` where `req.originalUrl`
36 does not change will return a cached parsed object, rather than parsing again.
41 $ npm run-script bench
43 > parseurl@1.3.1 bench nodejs-parseurl
44 > node benchmark/index.js
46 > node benchmark/fullurl.js
48 Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy"
54 fasturl x 1,290,780 ops/sec ±0.46% (195 runs sampled)
55 nativeurl x 56,401 ops/sec ±0.22% (196 runs sampled)
56 parseurl x 55,231 ops/sec ±0.22% (194 runs sampled)
58 > node benchmark/pathquery.js
60 Parsing URL "/foo/bar?user=tj&pet=fluffy"
66 fasturl x 1,986,668 ops/sec ±0.27% (190 runs sampled)
67 nativeurl x 98,740 ops/sec ±0.21% (195 runs sampled)
68 parseurl x 2,628,171 ops/sec ±0.36% (195 runs sampled)
70 > node benchmark/samerequest.js
72 Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object
78 fasturl x 2,184,468 ops/sec ±0.40% (194 runs sampled)
79 nativeurl x 99,437 ops/sec ±0.71% (194 runs sampled)
80 parseurl x 10,498,005 ops/sec ±0.61% (186 runs sampled)
82 > node benchmark/simplepath.js
84 Parsing URL "/foo/bar"
90 fasturl x 4,535,825 ops/sec ±0.27% (191 runs sampled)
91 nativeurl x 98,769 ops/sec ±0.54% (191 runs sampled)
92 parseurl x 4,164,865 ops/sec ±0.34% (192 runs sampled)
94 > node benchmark/slash.js
102 fasturl x 4,908,405 ops/sec ±0.42% (191 runs sampled)
103 nativeurl x 100,945 ops/sec ±0.59% (188 runs sampled)
104 parseurl x 4,333,208 ops/sec ±0.27% (194 runs sampled)
111 [npm-image]: https://img.shields.io/npm/v/parseurl.svg
112 [npm-url]: https://npmjs.org/package/parseurl
113 [node-version-image]: https://img.shields.io/node/v/parseurl.svg
114 [node-version-url]: http://nodejs.org/download/
115 [travis-image]: https://img.shields.io/travis/pillarjs/parseurl/master.svg
116 [travis-url]: https://travis-ci.org/pillarjs/parseurl
117 [coveralls-image]: https://img.shields.io/coveralls/pillarjs/parseurl/master.svg
118 [coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master
119 [downloads-image]: https://img.shields.io/npm/dm/parseurl.svg
120 [downloads-url]: https://npmjs.org/package/parseurl