{"version":"1.0.0-next.24","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":{".":{"types":"./index.d.ts","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"},"_id":"@polka/url@1.0.0-next.24","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","gitHead":"b7a236f2b5490b296a14f8423c1dfbc35c060ac7","bugs":{"url":"https://github.com/lukeed/polka/issues"},"homepage":"https://github.com/lukeed/polka#readme","_nodeVersion":"20.8.1","_npmVersion":"10.1.0","dist":{"integrity":"sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==","shasum":"58601079e11784d20f82d0585865bb42305c4df3","tarball":"http://registry-npm.ywwl.com/@polka/url/download/@polka/url-1.0.0-next.24.tgz","fileCount":5,"unpackedSize":4382,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF6qF0pOv6Y8PNYs6BBORXMFXYSy47CTfzlNj7EhlkwFAiBDyrO0XGTi+0h884zyTJk3xswpDx0nqvXbf4iVjKY09Q=="}],"size":1906,"noattachment":false,"key":"/@polka/url/-/@polka/url-1.0.0-next.24.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.24_1701707100449_0.86811340470757"},"_hasShrinkwrap":false,"publish_time":1701707100639,"_cnpm_publish_time":1701707100639,"dist-tags":{"latest":"0.5.0","next":"1.0.0-next.29"}}