{"version":"1.0.0-next.11","name":"@polka/url","repository":{"type":"git","url":"git+https://github.com/lukeed/polka.git"},"description":"Super fast, memoized `req.url` parser","module":"build.mjs","main":"build.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke@lukeed.com","url":"https://lukeed.com"},"publishConfig":{"access":"public"},"gitHead":"4edc74c28fde992eb10e23a6f6f4fd6040ccb34a","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// Example with `toDecode` param\nreq = { url: '/f%C3%B8%C3%B8%C3%9F%E2%88%82r?phone=%2b8675309' };\nparse(req, true);\n//=> { search: '?phone=+8675309',\n//=>   query: { phone: '+8675309' },\n//=>   pathname: '/føøß∂r',\n//=>   path: '/føøß∂r?phone=+8675309',\n//=>   href: '/føøß∂r?phone=+8675309',\n//=>   _raw: '/føøß∂r?phone=+8675309' }\n\n// Attaches awareness key\nassert(req._decoded); //=> true\n```\n\n## API\n\n### url(req, toDecode)\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#### toDecode\nType: `Boolean`<br>\nDefault: `false`\n\nIf enabled, the `url` will be fully decoded (via [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)) and the output keys will be slightly different:\n\n* `path`, `pathname`, `href`, `_raw` &mdash; will be the decoded strings\n* `search` &mdash; if there is a value, will be decoded string, else remain `null`\n* `query` &mdash; if there is a value, will be a decoded **object**, else remain `null`\n\nAdditionally, the `req` is mutated with `req._decoded = true` so as to prevent repetitive decoding.\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.11","_nodeVersion":"10.13.0","_npmVersion":"lerna/3.13.4/node@v10.13.0+x64 (darwin)","dist":{"integrity":"sha512-3NsZsJIA/22P3QUyrEDNA2D133H4j224twJrdipXN38dpnIOzAbUDtOwkcJ5pXmn75w7LSQDjA4tO9dm1XlqlA==","shasum":"aeb16f50649a91af79dbe36574b66d0f9e4d9f71","tarball":"http://registry-npm.ywwl.com/@polka/url/download/@polka/url-1.0.0-next.11.tgz","fileCount":5,"unpackedSize":6953,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHIN2CRA9TVsSAnZWagAAPYgP/R6FHMunm/xNwk6D/XY6\nIJmkhlqywyIETLSBpkEP83B7CcXlWR0ITO8Veqo1xfDRqCvpHf4n1BWSvK9x\nIj4zyXBQLLGn4Ee3em05CHgAAzZD79BrBMYkhviVVpN9BtAo/fDNW41CUeI6\nNPuSKXZDjklTZO6GGR0XsRMuBX2I0zK4kQ3pw4a9JpffDcVnL40PpvFPFqvR\nTe0nLhMAR7dtwv0eHJF/xrmCGbGo6Dh8vpixEwAE3npX6ITR0RLxI6kMUPsX\npEhIx6terN1TmvfKHBCuimubvlKlP0W2GozNi6xMSGs6g5HzLVaqigjcI0zC\nLL1Rkk7zNZG4JYS8aOKyz+ca/AwhzBrU5nNpH/Cg7DHitwnFlgHLDJ7mzZHY\n6GIzWHXRf0VUhFG4iL8nJ+tKcBLaTvwDToj3CzfaO19XxgPW2mX4eoIL5Wxt\nZ2lRdj1BVAjlX2+NrRXjyXxbFl3+oSbjIXTu6FXZ30yytKSbkdhH4H8Lk/lf\nyMhblkMeThrNNm3J2QyybFCKrCWqJu80Zd/RByBIMLqMt3rnSBigYfgJ/mv+\nxjjRoJGRmjygyb60D4g1jANguQllBgk485U4ohTX9wLbBBpSwmWDwqBvMWKb\nUq4eU9mSZPEFE69gXnQ2HO3vjfDdzcRAxngD0aNJhkg6hZnFMajg6ASP5w0P\nJwGM\r\n=3A5B\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMvc3jxgDEgEMG9TOjvW0Hitp+4gjifR7K9c3jCk9N8QIhAObVb5X1uI1OdbWK/eMJ5TlwteDYnFLlfs38LnGgZxxp"}],"size":3014,"noattachment":false,"key":"/@polka/url/-/@polka/url-1.0.0-next.11.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.11_1578926966458_0.631422984402525"},"_hasShrinkwrap":false,"publish_time":1578926966566,"_cnpm_publish_time":1578926966566,"dist-tags":{"latest":"0.5.0","next":"1.0.0-next.29"}}