root / HServer / 00.Server / 00.Program / node_modules / parseurl / README.md
이력 | 보기 | 이력해설 | 다운로드 (3.55 KB)
1 |
# parseurl |
---|---|
2 |
|
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] |
8 |
|
9 |
Parse a URL with memoization. |
10 |
|
11 |
## Install |
12 |
|
13 |
This is a [Node.js](https://nodejs.org/en/) module available through the |
14 |
[npm registry](https://www.npmjs.com/). Installation is done using the |
15 |
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): |
16 |
|
17 |
```sh |
18 |
$ npm install parseurl |
19 |
``` |
20 |
|
21 |
## API |
22 |
|
23 |
```js |
24 |
var parseurl = require('parseurl') |
25 |
``` |
26 |
|
27 |
### parseurl(req) |
28 |
|
29 |
Parse the URL of the given request object (looks at the `req.url` property) |
30 |
and return the result. The result is the same as `url.parse` in Node.js core. |
31 |
Calling this function multiple times on the same `req` where `req.url` does |
32 |
not change will return a cached parsed object, rather than parsing again. |
33 |
|
34 |
### parseurl.original(req) |
35 |
|
36 |
Parse the original URL of the given request object and return the result. |
37 |
This works by trying to parse `req.originalUrl` if it is a string, otherwise |
38 |
parses `req.url`. The result is the same as `url.parse` in Node.js core. |
39 |
Calling this function multiple times on the same `req` where `req.originalUrl` |
40 |
does not change will return a cached parsed object, rather than parsing again. |
41 |
|
42 |
## Benchmark |
43 |
|
44 |
```bash |
45 |
$ npm run-script bench |
46 |
|
47 |
> parseurl@1.3.2 bench nodejs-parseurl |
48 |
> node benchmark/index.js |
49 |
|
50 |
http_parser@2.7.0 |
51 |
node@4.8.4 |
52 |
v8@4.5.103.47 |
53 |
uv@1.9.1 |
54 |
zlib@1.2.11 |
55 |
ares@1.10.1-DEV |
56 |
icu@56.1 |
57 |
modules@46 |
58 |
openssl@1.0.2k |
59 |
|
60 |
> node benchmark/fullurl.js |
61 |
|
62 |
Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy" |
63 |
|
64 |
3 tests completed. |
65 |
|
66 |
fasturl x 1,246,766 ops/sec ±0.74% (188 runs sampled) |
67 |
nativeurl x 91,536 ops/sec ±0.54% (189 runs sampled) |
68 |
parseurl x 90,645 ops/sec ±0.38% (189 runs sampled) |
69 |
|
70 |
> node benchmark/pathquery.js |
71 |
|
72 |
Parsing URL "/foo/bar?user=tj&pet=fluffy" |
73 |
|
74 |
3 tests completed. |
75 |
|
76 |
fasturl x 2,077,650 ops/sec ±0.69% (186 runs sampled) |
77 |
nativeurl x 638,669 ops/sec ±0.67% (189 runs sampled) |
78 |
parseurl x 2,431,842 ops/sec ±0.71% (189 runs sampled) |
79 |
|
80 |
> node benchmark/samerequest.js |
81 |
|
82 |
Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object |
83 |
|
84 |
3 tests completed. |
85 |
|
86 |
fasturl x 2,135,391 ops/sec ±0.69% (188 runs sampled) |
87 |
nativeurl x 672,809 ops/sec ±3.83% (186 runs sampled) |
88 |
parseurl x 11,604,947 ops/sec ±0.70% (189 runs sampled) |
89 |
|
90 |
> node benchmark/simplepath.js |
91 |
|
92 |
Parsing URL "/foo/bar" |
93 |
|
94 |
3 tests completed. |
95 |
|
96 |
fasturl x 4,961,391 ops/sec ±0.97% (186 runs sampled) |
97 |
nativeurl x 914,931 ops/sec ±0.83% (186 runs sampled) |
98 |
parseurl x 7,559,196 ops/sec ±0.66% (188 runs sampled) |
99 |
|
100 |
> node benchmark/slash.js |
101 |
|
102 |
Parsing URL "/" |
103 |
|
104 |
3 tests completed. |
105 |
|
106 |
fasturl x 4,053,379 ops/sec ±0.91% (187 runs sampled) |
107 |
nativeurl x 963,999 ops/sec ±0.58% (189 runs sampled) |
108 |
parseurl x 11,516,143 ops/sec ±0.58% (188 runs sampled) |
109 |
``` |
110 |
|
111 |
## License |
112 |
|
113 |
[MIT](LICENSE) |
114 |
|
115 |
[npm-image]: https://img.shields.io/npm/v/parseurl.svg |
116 |
[npm-url]: https://npmjs.org/package/parseurl |
117 |
[node-version-image]: https://img.shields.io/node/v/parseurl.svg |
118 |
[node-version-url]: https://nodejs.org/en/download/ |
119 |
[travis-image]: https://img.shields.io/travis/pillarjs/parseurl/master.svg |
120 |
[travis-url]: https://travis-ci.org/pillarjs/parseurl |
121 |
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/parseurl/master.svg |
122 |
[coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master |
123 |
[downloads-image]: https://img.shields.io/npm/dm/parseurl.svg |
124 |
[downloads-url]: https://npmjs.org/package/parseurl |