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 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # parseurl
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Node.js Version][node-version-image]][node-version-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.2 bench nodejs-parseurl
  34. > node benchmark/index.js
  35. http_parser@2.7.0
  36. node@4.8.4
  37. v8@4.5.103.47
  38. uv@1.9.1
  39. zlib@1.2.11
  40. ares@1.10.1-DEV
  41. icu@56.1
  42. modules@46
  43. openssl@1.0.2k
  44. > node benchmark/fullurl.js
  45. Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy"
  46. 3 tests completed.
  47. fasturl x 1,246,766 ops/sec ±0.74% (188 runs sampled)
  48. nativeurl x 91,536 ops/sec ±0.54% (189 runs sampled)
  49. parseurl x 90,645 ops/sec ±0.38% (189 runs sampled)
  50. > node benchmark/pathquery.js
  51. Parsing URL "/foo/bar?user=tj&pet=fluffy"
  52. 3 tests completed.
  53. fasturl x 2,077,650 ops/sec ±0.69% (186 runs sampled)
  54. nativeurl x 638,669 ops/sec ±0.67% (189 runs sampled)
  55. parseurl x 2,431,842 ops/sec ±0.71% (189 runs sampled)
  56. > node benchmark/samerequest.js
  57. Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object
  58. 3 tests completed.
  59. fasturl x 2,135,391 ops/sec ±0.69% (188 runs sampled)
  60. nativeurl x 672,809 ops/sec ±3.83% (186 runs sampled)
  61. parseurl x 11,604,947 ops/sec ±0.70% (189 runs sampled)
  62. > node benchmark/simplepath.js
  63. Parsing URL "/foo/bar"
  64. 3 tests completed.
  65. fasturl x 4,961,391 ops/sec ±0.97% (186 runs sampled)
  66. nativeurl x 914,931 ops/sec ±0.83% (186 runs sampled)
  67. parseurl x 7,559,196 ops/sec ±0.66% (188 runs sampled)
  68. > node benchmark/slash.js
  69. Parsing URL "/"
  70. 3 tests completed.
  71. fasturl x 4,053,379 ops/sec ±0.91% (187 runs sampled)
  72. nativeurl x 963,999 ops/sec ±0.58% (189 runs sampled)
  73. parseurl x 11,516,143 ops/sec ±0.58% (188 runs sampled)
  74. ```
  75. ## License
  76. [MIT](LICENSE)
  77. [npm-image]: https://img.shields.io/npm/v/parseurl.svg
  78. [npm-url]: https://npmjs.org/package/parseurl
  79. [node-version-image]: https://img.shields.io/node/v/parseurl.svg
  80. [node-version-url]: https://nodejs.org/en/download/
  81. [travis-image]: https://img.shields.io/travis/pillarjs/parseurl/master.svg
  82. [travis-url]: https://travis-ci.org/pillarjs/parseurl
  83. [coveralls-image]: https://img.shields.io/coveralls/pillarjs/parseurl/master.svg
  84. [coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master
  85. [downloads-image]: https://img.shields.io/npm/dm/parseurl.svg
  86. [downloads-url]: https://npmjs.org/package/parseurl