Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # parseurl
  2. [![NPM Version][npm-version-image]][npm-url]
  3. [![NPM Downloads][npm-downloads-image]][npm-url]
  4. [![Node.js Version][node-image]][node-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. Parse a URL with memoization.
  8. ## Install
  9. This is a [Node.js](https://nodejs.org/en/) module available through the
  10. [npm registry](https://www.npmjs.com/). Installation is done using the
  11. [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
  12. ```sh
  13. $ npm install parseurl
  14. ```
  15. ## API
  16. ```js
  17. var parseurl = require('parseurl')
  18. ```
  19. ### parseurl(req)
  20. Parse the URL of the given request object (looks at the `req.url` property)
  21. and return the result. The result is the same as `url.parse` in Node.js core.
  22. Calling this function multiple times on the same `req` where `req.url` does
  23. not change will return a cached parsed object, rather than parsing again.
  24. ### parseurl.original(req)
  25. Parse the original URL of the given request object and return the result.
  26. This works by trying to parse `req.originalUrl` if it is a string, otherwise
  27. parses `req.url`. The result is the same as `url.parse` in Node.js core.
  28. Calling this function multiple times on the same `req` where `req.originalUrl`
  29. does not change will return a cached parsed object, rather than parsing again.
  30. ## Benchmark
  31. ```bash
  32. $ npm run-script bench
  33. > parseurl@1.3.3 bench nodejs-parseurl
  34. > node benchmark/index.js
  35. http_parser@2.8.0
  36. node@10.6.0
  37. v8@6.7.288.46-node.13
  38. uv@1.21.0
  39. zlib@1.2.11
  40. ares@1.14.0
  41. modules@64
  42. nghttp2@1.32.0
  43. napi@3
  44. openssl@1.1.0h
  45. icu@61.1
  46. unicode@10.0
  47. cldr@33.0
  48. tz@2018c
  49. > node benchmark/fullurl.js
  50. Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy"
  51. 4 tests completed.
  52. fasturl x 2,207,842 ops/sec ±3.76% (184 runs sampled)
  53. nativeurl - legacy x 507,180 ops/sec ±0.82% (191 runs sampled)
  54. nativeurl - whatwg x 290,044 ops/sec ±1.96% (189 runs sampled)
  55. parseurl x 488,907 ops/sec ±2.13% (192 runs sampled)
  56. > node benchmark/pathquery.js
  57. Parsing URL "/foo/bar?user=tj&pet=fluffy"
  58. 4 tests completed.
  59. fasturl x 3,812,564 ops/sec ±3.15% (188 runs sampled)
  60. nativeurl - legacy x 2,651,631 ops/sec ±1.68% (189 runs sampled)
  61. nativeurl - whatwg x 161,837 ops/sec ±2.26% (189 runs sampled)
  62. parseurl x 4,166,338 ops/sec ±2.23% (184 runs sampled)
  63. > node benchmark/samerequest.js
  64. Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object
  65. 4 tests completed.
  66. fasturl x 3,821,651 ops/sec ±2.42% (185 runs sampled)
  67. nativeurl - legacy x 2,651,162 ops/sec ±1.90% (187 runs sampled)
  68. nativeurl - whatwg x 175,166 ops/sec ±1.44% (188 runs sampled)
  69. parseurl x 14,912,606 ops/sec ±3.59% (183 runs sampled)
  70. > node benchmark/simplepath.js
  71. Parsing URL "/foo/bar"
  72. 4 tests completed.
  73. fasturl x 12,421,765 ops/sec ±2.04% (191 runs sampled)
  74. nativeurl - legacy x 7,546,036 ops/sec ±1.41% (188 runs sampled)
  75. nativeurl - whatwg x 198,843 ops/sec ±1.83% (189 runs sampled)
  76. parseurl x 24,244,006 ops/sec ±0.51% (194 runs sampled)
  77. > node benchmark/slash.js
  78. Parsing URL "/"
  79. 4 tests completed.
  80. fasturl x 17,159,456 ops/sec ±3.25% (188 runs sampled)
  81. nativeurl - legacy x 11,635,097 ops/sec ±3.79% (184 runs sampled)
  82. nativeurl - whatwg x 240,693 ops/sec ±0.83% (189 runs sampled)
  83. parseurl x 42,279,067 ops/sec ±0.55% (190 runs sampled)
  84. ```
  85. ## License
  86. [MIT](LICENSE)
  87. [coveralls-image]: https://badgen.net/coveralls/c/github/pillarjs/parseurl/master
  88. [coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master
  89. [node-image]: https://badgen.net/npm/node/parseurl
  90. [node-url]: https://nodejs.org/en/download
  91. [npm-downloads-image]: https://badgen.net/npm/dm/parseurl
  92. [npm-url]: https://npmjs.org/package/parseurl
  93. [npm-version-image]: https://badgen.net/npm/v/parseurl
  94. [travis-image]: https://badgen.net/travis/pillarjs/parseurl/master
  95. [travis-url]: https://travis-ci.org/pillarjs/parseurl