Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / dgbuilder / dgeflows / node_modules / express / node_modules / parseurl / README.md
1 # parseurl
2
3 [![NPM version](https://badge.fury.io/js/parseurl.svg)](http://badge.fury.io/js/parseurl)
4 [![Build Status](https://travis-ci.org/expressjs/parseurl.svg?branch=master)](https://travis-ci.org/expressjs/parseurl)
5 [![Coverage Status](https://img.shields.io/coveralls/expressjs/parseurl.svg?branch=master)](https://coveralls.io/r/expressjs/parseurl)
6
7 Parse a URL with memoization.
8
9 ## Install
10
11 ```bash
12 $ npm install parseurl
13 ```
14
15 ## API
16
17 ```js
18 var parseurl = require('parseurl')
19 ```
20
21 ### parseurl(req)
22
23 Parse the URL of the given request object (looks at the `req.url` property)
24 and return the result. The result is the same as `url.parse` in Node.js core.
25 Calling this function multiple times on the same `req` where `req.url` does
26 not change will return a cached parsed object, rather than parsing again.
27
28 ### parseurl.original(req)
29
30 Parse the original URL of the given request object and return the result.
31 This works by trying to parse `req.originalUrl` if it is a string, otherwise
32 parses `req.url`. The result is the same as `url.parse` in Node.js core.
33 Calling this function multiple times on the same `req` where `req.originalUrl`
34 does not change will return a cached parsed object, rather than parsing again.
35
36 ## Benchmark
37
38 ```bash
39 $ npm run-script bench
40
41 > parseurl@1.3.0 bench nodejs-parseurl
42 > node benchmark/index.js
43
44 > node benchmark/fullurl.js
45
46   Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy"
47
48   1 test completed.
49   2 tests completed.
50   3 tests completed.
51
52   fasturl   x 1,290,780 ops/sec ±0.46% (195 runs sampled)
53   nativeurl x    56,401 ops/sec ±0.22% (196 runs sampled)
54   parseurl  x    55,231 ops/sec ±0.22% (194 runs sampled)
55
56 > node benchmark/pathquery.js
57
58   Parsing URL "/foo/bar?user=tj&pet=fluffy"
59
60   1 test completed.
61   2 tests completed.
62   3 tests completed.
63
64   fasturl   x 1,986,668 ops/sec ±0.27% (190 runs sampled)
65   nativeurl x    98,740 ops/sec ±0.21% (195 runs sampled)
66   parseurl  x 2,628,171 ops/sec ±0.36% (195 runs sampled)
67
68 > node benchmark/samerequest.js
69
70   Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object
71
72   1 test completed.
73   2 tests completed.
74   3 tests completed.
75
76   fasturl   x  2,184,468 ops/sec ±0.40% (194 runs sampled)
77   nativeurl x     99,437 ops/sec ±0.71% (194 runs sampled)
78   parseurl  x 10,498,005 ops/sec ±0.61% (186 runs sampled)
79
80 > node benchmark/simplepath.js
81
82   Parsing URL "/foo/bar"
83
84   1 test completed.
85   2 tests completed.
86   3 tests completed.
87
88   fasturl   x 4,535,825 ops/sec ±0.27% (191 runs sampled)
89   nativeurl x    98,769 ops/sec ±0.54% (191 runs sampled)
90   parseurl  x 4,164,865 ops/sec ±0.34% (192 runs sampled)
91
92 > node benchmark/slash.js
93
94   Parsing URL "/"
95
96   1 test completed.
97   2 tests completed.
98   3 tests completed.
99
100   fasturl   x 4,908,405 ops/sec ±0.42% (191 runs sampled)
101   nativeurl x   100,945 ops/sec ±0.59% (188 runs sampled)
102   parseurl  x 4,333,208 ops/sec ±0.27% (194 runs sampled)
103 ```
104
105 ## License
106
107   [MIT](LICENSE)