summaryrefslogtreecommitdiffstats
path: root/middleware/node_modules/parseurl
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/node_modules/parseurl')
-rw-r--r--middleware/node_modules/parseurl/HISTORY.md58
-rw-r--r--middleware/node_modules/parseurl/LICENSE24
-rw-r--r--middleware/node_modules/parseurl/README.md133
-rw-r--r--middleware/node_modules/parseurl/index.js158
-rw-r--r--middleware/node_modules/parseurl/package.json40
5 files changed, 413 insertions, 0 deletions
diff --git a/middleware/node_modules/parseurl/HISTORY.md b/middleware/node_modules/parseurl/HISTORY.md
new file mode 100644
index 0000000..8e40954
--- /dev/null
+++ b/middleware/node_modules/parseurl/HISTORY.md
@@ -0,0 +1,58 @@
+1.3.3 / 2019-04-15
+==================
+
+ * Fix Node.js 0.8 return value inconsistencies
+
+1.3.2 / 2017-09-09
+==================
+
+ * perf: reduce overhead for full URLs
+ * perf: unroll the "fast-path" `RegExp`
+
+1.3.1 / 2016-01-17
+==================
+
+ * perf: enable strict mode
+
+1.3.0 / 2014-08-09
+==================
+
+ * Add `parseurl.original` for parsing `req.originalUrl` with fallback
+ * Return `undefined` if `req.url` is `undefined`
+
+1.2.0 / 2014-07-21
+==================
+
+ * Cache URLs based on original value
+ * Remove no-longer-needed URL mis-parse work-around
+ * Simplify the "fast-path" `RegExp`
+
+1.1.3 / 2014-07-08
+==================
+
+ * Fix typo
+
+1.1.2 / 2014-07-08
+==================
+
+ * Seriously fix Node.js 0.8 compatibility
+
+1.1.1 / 2014-07-08
+==================
+
+ * Fix Node.js 0.8 compatibility
+
+1.1.0 / 2014-07-08
+==================
+
+ * Incorporate URL href-only parse fast-path
+
+1.0.1 / 2014-03-08
+==================
+
+ * Add missing `require`
+
+1.0.0 / 2014-03-08
+==================
+
+ * Genesis from `connect`
diff --git a/middleware/node_modules/parseurl/LICENSE b/middleware/node_modules/parseurl/LICENSE
new file mode 100644
index 0000000..27653d3
--- /dev/null
+++ b/middleware/node_modules/parseurl/LICENSE
@@ -0,0 +1,24 @@
+
+(The MIT License)
+
+Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
+Copyright (c) 2014-2017 Douglas Christopher Wilson <doug@somethingdoug.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/middleware/node_modules/parseurl/README.md b/middleware/node_modules/parseurl/README.md
new file mode 100644
index 0000000..443e716
--- /dev/null
+++ b/middleware/node_modules/parseurl/README.md
@@ -0,0 +1,133 @@
+# parseurl
+
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
+[![Node.js Version][node-image]][node-url]
+[![Build Status][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+Parse a URL with memoization.
+
+## Install
+
+This is a [Node.js](https://nodejs.org/en/) module available through the
+[npm registry](https://www.npmjs.com/). Installation is done using the
+[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
+
+```sh
+$ npm install parseurl
+```
+
+## API
+
+```js
+var parseurl = require('parseurl')
+```
+
+### parseurl(req)
+
+Parse the URL of the given request object (looks at the `req.url` property)
+and return the result. The result is the same as `url.parse` in Node.js core.
+Calling this function multiple times on the same `req` where `req.url` does
+not change will return a cached parsed object, rather than parsing again.
+
+### parseurl.original(req)
+
+Parse the original URL of the given request object and return the result.
+This works by trying to parse `req.originalUrl` if it is a string, otherwise
+parses `req.url`. The result is the same as `url.parse` in Node.js core.
+Calling this function multiple times on the same `req` where `req.originalUrl`
+does not change will return a cached parsed object, rather than parsing again.
+
+## Benchmark
+
+```bash
+$ npm run-script bench
+
+> parseurl@1.3.3 bench nodejs-parseurl
+> node benchmark/index.js
+
+ http_parser@2.8.0
+ node@10.6.0
+ v8@6.7.288.46-node.13
+ uv@1.21.0
+ zlib@1.2.11
+ ares@1.14.0
+ modules@64
+ nghttp2@1.32.0
+ napi@3
+ openssl@1.1.0h
+ icu@61.1
+ unicode@10.0
+ cldr@33.0
+ tz@2018c
+
+> node benchmark/fullurl.js
+
+ Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy"
+
+ 4 tests completed.
+
+ fasturl x 2,207,842 ops/sec ±3.76% (184 runs sampled)
+ nativeurl - legacy x 507,180 ops/sec ±0.82% (191 runs sampled)
+ nativeurl - whatwg x 290,044 ops/sec ±1.96% (189 runs sampled)
+ parseurl x 488,907 ops/sec ±2.13% (192 runs sampled)
+
+> node benchmark/pathquery.js
+
+ Parsing URL "/foo/bar?user=tj&pet=fluffy"
+
+ 4 tests completed.
+
+ fasturl x 3,812,564 ops/sec ±3.15% (188 runs sampled)
+ nativeurl - legacy x 2,651,631 ops/sec ±1.68% (189 runs sampled)
+ nativeurl - whatwg x 161,837 ops/sec ±2.26% (189 runs sampled)
+ parseurl x 4,166,338 ops/sec ±2.23% (184 runs sampled)
+
+> node benchmark/samerequest.js
+
+ Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object
+
+ 4 tests completed.
+
+ fasturl x 3,821,651 ops/sec ±2.42% (185 runs sampled)
+ nativeurl - legacy x 2,651,162 ops/sec ±1.90% (187 runs sampled)
+ nativeurl - whatwg x 175,166 ops/sec ±1.44% (188 runs sampled)
+ parseurl x 14,912,606 ops/sec ±3.59% (183 runs sampled)
+
+> node benchmark/simplepath.js
+
+ Parsing URL "/foo/bar"
+
+ 4 tests completed.
+
+ fasturl x 12,421,765 ops/sec ±2.04% (191 runs sampled)
+ nativeurl - legacy x 7,546,036 ops/sec ±1.41% (188 runs sampled)
+ nativeurl - whatwg x 198,843 ops/sec ±1.83% (189 runs sampled)
+ parseurl x 24,244,006 ops/sec ±0.51% (194 runs sampled)
+
+> node benchmark/slash.js
+
+ Parsing URL "/"
+
+ 4 tests completed.
+
+ fasturl x 17,159,456 ops/sec ±3.25% (188 runs sampled)
+ nativeurl - legacy x 11,635,097 ops/sec ±3.79% (184 runs sampled)
+ nativeurl - whatwg x 240,693 ops/sec ±0.83% (189 runs sampled)
+ parseurl x 42,279,067 ops/sec ±0.55% (190 runs sampled)
+```
+
+## License
+
+ [MIT](LICENSE)
+
+[coveralls-image]: https://badgen.net/coveralls/c/github/pillarjs/parseurl/master
+[coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master
+[node-image]: https://badgen.net/npm/node/parseurl
+[node-url]: https://nodejs.org/en/download
+[npm-downloads-image]: https://badgen.net/npm/dm/parseurl
+[npm-url]: https://npmjs.org/package/parseurl
+[npm-version-image]: https://badgen.net/npm/v/parseurl
+[travis-image]: https://badgen.net/travis/pillarjs/parseurl/master
+[travis-url]: https://travis-ci.org/pillarjs/parseurl
diff --git a/middleware/node_modules/parseurl/index.js b/middleware/node_modules/parseurl/index.js
new file mode 100644
index 0000000..ece7223
--- /dev/null
+++ b/middleware/node_modules/parseurl/index.js
@@ -0,0 +1,158 @@
+/*!
+ * parseurl
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var url = require('url')
+var parse = url.parse
+var Url = url.Url
+
+/**
+ * Module exports.
+ * @public
+ */
+
+module.exports = parseurl
+module.exports.original = originalurl
+
+/**
+ * Parse the `req` url with memoization.
+ *
+ * @param {ServerRequest} req
+ * @return {Object}
+ * @public
+ */
+
+function parseurl (req) {
+ var url = req.url
+
+ if (url === undefined) {
+ // URL is undefined
+ return undefined
+ }
+
+ var parsed = req._parsedUrl
+
+ if (fresh(url, parsed)) {
+ // Return cached URL parse
+ return parsed
+ }
+
+ // Parse the URL
+ parsed = fastparse(url)
+ parsed._raw = url
+
+ return (req._parsedUrl = parsed)
+};
+
+/**
+ * Parse the `req` original url with fallback and memoization.
+ *
+ * @param {ServerRequest} req
+ * @return {Object}
+ * @public
+ */
+
+function originalurl (req) {
+ var url = req.originalUrl
+
+ if (typeof url !== 'string') {
+ // Fallback
+ return parseurl(req)
+ }
+
+ var parsed = req._parsedOriginalUrl
+
+ if (fresh(url, parsed)) {
+ // Return cached URL parse
+ return parsed
+ }
+
+ // Parse the URL
+ parsed = fastparse(url)
+ parsed._raw = url
+
+ return (req._parsedOriginalUrl = parsed)
+};
+
+/**
+ * Parse the `str` url with fast-path short-cut.
+ *
+ * @param {string} str
+ * @return {Object}
+ * @private
+ */
+
+function fastparse (str) {
+ if (typeof str !== 'string' || str.charCodeAt(0) !== 0x2f /* / */) {
+ return parse(str)
+ }
+
+ var pathname = str
+ var query = null
+ var search = null
+
+ // This takes the regexp from https://github.com/joyent/node/pull/7878
+ // Which is /^(\/[^?#\s]*)(\?[^#\s]*)?$/
+ // And unrolls it into a for loop
+ for (var i = 1; i < str.length; i++) {
+ switch (str.charCodeAt(i)) {
+ case 0x3f: /* ? */
+ if (search === null) {
+ pathname = str.substring(0, i)
+ query = str.substring(i + 1)
+ search = str.substring(i)
+ }
+ break
+ case 0x09: /* \t */
+ case 0x0a: /* \n */
+ case 0x0c: /* \f */
+ case 0x0d: /* \r */
+ case 0x20: /* */
+ case 0x23: /* # */
+ case 0xa0:
+ case 0xfeff:
+ return parse(str)
+ }
+ }
+
+ var url = Url !== undefined
+ ? new Url()
+ : {}
+
+ url.path = str
+ url.href = str
+ url.pathname = pathname
+
+ if (search !== null) {
+ url.query = query
+ url.search = search
+ }
+
+ return url
+}
+
+/**
+ * Determine if parsed is still fresh for url.
+ *
+ * @param {string} url
+ * @param {object} parsedUrl
+ * @return {boolean}
+ * @private
+ */
+
+function fresh (url, parsedUrl) {
+ return typeof parsedUrl === 'object' &&
+ parsedUrl !== null &&
+ (Url === undefined || parsedUrl instanceof Url) &&
+ parsedUrl._raw === url
+}
diff --git a/middleware/node_modules/parseurl/package.json b/middleware/node_modules/parseurl/package.json
new file mode 100644
index 0000000..6b443ca
--- /dev/null
+++ b/middleware/node_modules/parseurl/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "parseurl",
+ "description": "parse a url with memoization",
+ "version": "1.3.3",
+ "contributors": [
+ "Douglas Christopher Wilson <doug@somethingdoug.com>",
+ "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
+ ],
+ "repository": "pillarjs/parseurl",
+ "license": "MIT",
+ "devDependencies": {
+ "beautify-benchmark": "0.2.4",
+ "benchmark": "2.1.4",
+ "eslint": "5.16.0",
+ "eslint-config-standard": "12.0.0",
+ "eslint-plugin-import": "2.17.1",
+ "eslint-plugin-node": "7.0.1",
+ "eslint-plugin-promise": "4.1.1",
+ "eslint-plugin-standard": "4.0.0",
+ "fast-url-parser": "1.1.3",
+ "istanbul": "0.4.5",
+ "mocha": "6.1.3"
+ },
+ "files": [
+ "LICENSE",
+ "HISTORY.md",
+ "README.md",
+ "index.js"
+ ],
+ "engines": {
+ "node": ">= 0.8"
+ },
+ "scripts": {
+ "bench": "node benchmark/index.js",
+ "lint": "eslint .",
+ "test": "mocha --check-leaks --bail --reporter spec test/",
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot test/",
+ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec test/"
+ }
+}