{"version":"1.0.0-next.20","name":"@polka/url","repository":{"type":"git","url":"git+https://github.com/lukeed/polka.git"},"description":"Super fast, memoized `req.url` parser","module":"build.mjs","types":"index.d.ts","main":"build.js","license":"MIT","exports":{".":{"import":"./build.mjs","require":"./build.js"},"./package.json":"./package.json"},"author":{"name":"Luke Edwards","email":"luke@lukeed.com","url":"https://lukeed.com"},"publishConfig":{"access":"public"},"gitHead":"daa2c85fac5d5ac06d7c678018cc55eed00ae95a","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`, 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, avoiding the need to fully parse 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 = {\n  url: '/foo/bar?fizz=buzz'\n};\nlet output = parse(req);\n//=> {\n//=>   pathname: '/foo/bar',\n//=>   raw: '/foo/bar?fizz=buzz',\n//=>   search: '?fizz=buzz',\n//=>   query: {\n//=>     fizz: 'buzz'\n//=>   },\n//=> }\n\n// Attaches result for future memoization\nassert.deepEqual(output, 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 `{ url: string }`\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\nCheck out the [`bench`](/bench) directory for in-depth benchmark results and comparisons.\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.20","_nodeVersion":"16.8.0","_npmVersion":"lerna/3.13.4/node@v16.8.0+x64 (darwin)","dist":{"integrity":"sha512-88p7+M0QGxKpmnkfXjS4V26AnoC/eiqZutE8GLdaI5X12NY75bXSdTY9NkmYb2Xyk1O+MmkuO6Frmsj84V6I8Q==","shasum":"111b5db0f501aa89b05076fa31f0ea0e0c292cd3","tarball":"http://registry-npm.ywwl.com/@polka/url/download/@polka/url-1.0.0-next.20.tgz","fileCount":6,"unpackedSize":5528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhKI7BCRA9TVsSAnZWagAAzuIQAIhqkPeEIBhi/vk3Syth\n5S9ms/0mL/ABvGUjQVG2CGuRLSQTChj2+22cBc9NRw5vB28Jwhzpm36kgKPM\nIg/BY8WPFBP1CHc6U0mo7JnGP6b8UUHktAzdQiSt0/zp/aqZZCNmm2bDCyvh\ndZ3/HOwSArCoV2YvLkvZnBOjYB496gc40UQUTZu671hU79DVMVjFv7ArLC2/\nDDKqKN/+klQoaJ2EbtW8ap19WHalB4jihHdB2QRs1FNO2D7JNIznQTB+xEVw\nVLBRCxjCM/VdPr0VV/EGeC8tIS7GgKvjP0OiFo9vlQkafrY/3Ms/BWha0yC6\nc0ursIHbXScvb6svNeR/VrDWixEFhzC8rJsOWnLFDkq8melhinws93JEbJcA\nYyq01BtXyhT4bHMuEBZGUEit8dQ+OB8GRSjvR8x6L0h7XEFouPdR65kG1yeq\nn13E4xAHY+1hyAiAf0vVsO/bOs7NyCwgr8yCLbqMhFwisO69lfnl7MxY0NSt\nQ0dnjbpLvMuROhUxLar3xRG2WVvxmVMcN0tPjHEEYm2xx7y4QZ5nc8XhKkux\n9kwAdvoBCWfl2mAij67bCxbw9q2o5vzCEToOs7KafBo/7XZatGVZiWP2zVQ9\n+ioDPf3UIIzEOfL/0WbIggSEf6DH1HHJO+PyyZjwcqu+ZLpLpvM0btCUaypv\nBx5E\r\n=FYOf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFr/kM+hV5mYQ6YSdnwZk/TOSsVxL3BGCdwiN73sQFHSAiEAycQc0u9gMT0qusE4lJT2OdmGCh5G6WnOdZqwJLrXfhg="}],"size":2631,"noattachment":false,"key":"/@polka/url/-/@polka/url-1.0.0-next.20.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/url_1.0.0-next.20_1630047937372_0.9774864116259563"},"_hasShrinkwrap":false,"publish_time":1630047937500,"_cnpm_publish_time":1630047937500,"dist-tags":{"latest":"0.5.0","next":"1.0.0-next.29"}}