{"version":"1.0.0-next.0","name":"@polka/url","repository":{"type":"git","url":"git+https://github.com/lukeed/polka.git"},"description":"Super fast, memoized `req.url` parser","license":"MIT","author":{"name":"Luke Edwards","email":"luke@lukeed.com","url":"https://lukeed.com"},"publishConfig":{"access":"public"},"gitHead":"3598f0c5a1b343b6a37f661084c1643e832ff701","readme":"# @polka/url [![npm](https://badgen.now.sh/npm/v/@polka/url)](https://npmjs.org/package/@polka/url)\n\n> Super fast, memoized `req.url` parser; _not_ limited to [Polka][polka]!\n\nParses the `url` from a [`IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) request. The returned object will always only contain the following keys: `search`, `query`, `pathname`, `path`, `href`, and `_raw`.\n\n> **Note:** This library does not process `protocol`, `hostname`, `port`, etc.<br>This is because the incoming `req.url` value only begins with the path information.\n\nParsed requests will be mutated with a `_parsedUrl` key, containing the returned output. This is used for future memoization, so as to avoid parsing the same `url` value multiple times.\n\n## Install\n\n```\n$ npm install --save @polka/url\n```\n\n## Usage\n\n```js\nconst parse = require('@polka/url');\n\nlet req = { url: '/foo/bar?fizz=buzz' };\nlet foo = parse(req);\n//=> { search: '?fizz=buzz',\n//=>   query: 'fizz=buzz',\n//=>   pathname: '/foo/bar',\n//=>   path: '/foo/bar?fizz=buzz',\n//=>   href: '/foo/bar?fizz=buzz',\n//=>   _raw: '/foo/bar?fizz=buzz' }\n\n// Attaches result for future memoization\nassert.deepEqual(foo, req._parsedUrl); //=> true\n```\n\n## API\n\n### url(req)\nReturns: `Object` or `undefined`\n\n> **Important:** The `req` must have a `url` key, otherwise `undefined` will be returned.<br>If no input is provided at all, a `TypeError` will be thrown.\n\n#### req\nType: `IncomingMessage` or `Object`\n\nThe incoming HTTP request (`req`) or a plain `Object` with a `url` key.\n\n> **Note:** In Node.js servers, the [`req.url`](https://nodejs.org/api/http.html#http_message_url) begins with a pathname & does not include a `hash`.\n\n\n## Benchmarks\n\n> Running the `parseurl` benchmark suite on Node 10.9.0\n\n```\nParsing: \"/foo/bar?user=tj&pet=fluffy\"\n  nativeurl  x  3,496,593 ops/sec ±0.78% (194 runs sampled)\n  parseurl   x  5,702,515 ops/sec ±0.59% (194 runs sampled)\n  @polka/url x 11,510,281 ops/sec ±1.93% (192 runs sampled)\n\nREPEAT: \"/foo/bar?user=tj&pet=fluffy\"\n  nativeurl  x  3,344,884 ops/sec ±0.13% (191 runs sampled)\n  parseurl   x 20,386,848 ops/sec ±0.22% (192 runs sampled)\n  @polka/url x 21,088,923 ops/sec ±0.58% (191 runs sampled)\n\nParsing: \"/foo/bar\"\n  nativeurl  x  9,808,119 ops/sec ±0.51% (190 runs sampled)\n  parseurl   x 26,186,627 ops/sec ±0.16% (195 runs sampled)\n  @polka/url x 43,946,765 ops/sec ±0.55% (194 runs sampled)\n\nParsing: \"/\"\n  nativeurl  x 15,698,746 ops/sec ±0.79% (192 runs sampled)\n  parseurl   x 36,861,339 ops/sec ±0.19% (195 runs sampled)\n  @polka/url x 48,295,119 ops/sec ±0.51% (194 runs sampled)\n```\n\n\n## Support\n\nAny issues or questions can be sent to the [Polka][polka] repository.<br>However, please specify that your inquiry is about `@polka/url` specifically.\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n\n[polka]: https://github.com/lukeed/polka\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/lukeed/polka/issues"},"homepage":"https://github.com/lukeed/polka#readme","_id":"@polka/url@1.0.0-next.0","_nodeVersion":"10.13.0","_npmVersion":"lerna/3.13.1/node@v10.13.0+x64 (darwin)","dist":{"integrity":"sha512-khlIazYuw74cnv6yK5iA4Snggo+ICeeqtWVZbzuHFdvEbVIf2veenitVjvTcZ4S9WD8NTd3Rl+HrVOATAA/qWw==","shasum":"818f693dd4ee2a742ff43dc789eccbcb6ba6efba","tarball":"http://registry-npm.ywwl.com/@polka/url/download/@polka/url-1.0.0-next.0.tgz","fileCount":4,"unpackedSize":5006,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJchL3sCRA9TVsSAnZWagAA0DAP/0Kumyh+lVIqGSwUpQxj\neRptsjCJ0254Egej1uoDACDbDtRZF0ho3Y4fSzEZFM+5/eQSoIcbK1Ij83be\nUZNp0ZmfBhpH+wa3ZBjL9Gfhe5q7ZBHpFAbsSaOtMWCiiyA2XoVdv0bphZtP\nMCDw7Klslt14EO9rCzXQPJ46rEfcdiYqMELmj4G4KBVRdBJsMNsM8R7Zf3UY\nIKIF/7f66fJzhM5li7D+mizE3mG/gEz28UL/c1tOVkWyU2TZKW6YtYg4X6lT\nHdRQBvXBZnw4A8pQ/wzGLGt/87xKYP3sYfptG74gc8WTPdSlAgv/7DvBKIlu\nBKwvKYD0sslGfwyfy7kKc0jjwP0prIHrdBOcNPHb5kpGf7Fg2WsdIaWWqyx4\nSUuI6SSFF1L+u1yw4X+qLi33jwZXyL2F9uv+i/5HfeIgu/Y7D5FPuiUhzBXN\nAi09c3ar+zUxpEWF/Te4hX8eWCnJwPmSrdzEM0t9xS9Tfk2FVHKS7bl1atC3\nKGJtLMgWwkxlUiNGZN2I0G+Spcunsz2JYBBNLWQZxO7oeQfOSRS2npPPKnaq\nOqgJnpCNVpz0sTdyb4JHZf9RPOqYtkh/dJEdzs7dPNiMH2bDK1dSClpL3PnY\nG2M4l1LsIKmE+nfUWI2CNvIEGTYwradzVgz5sd65pEl0MZ3atmNiWU1XJ4ma\nF02P\r\n=inoO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQ/yTzIrSmjRLg6eu9mSjTUH47W9cAX0JxvydFcxNtywIhALPmKO4eLZZgSy1kgRc03g8e6xZ0DmzEQPG0A3xT7Jb5"}],"size":2561,"noattachment":false,"key":"/@polka/url/-/@polka/url-1.0.0-next.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/url_1.0.0-next.0_1552203243849_0.9972463325570979"},"_hasShrinkwrap":false,"publish_time":1552203243975,"_cnpm_publish_time":1552203243975,"dist-tags":{"latest":"0.5.0","next":"1.0.0-next.29"}}