{"name":"native-url","version":"0.1.0","description":"Brings the node url api layer to whatwg-url class","source":"src/index.js","main":"dist/index.js","module":"dist/index.mjs","scripts":{"build":"microbundle","test":"yarn run build && jest"},"author":{"name":"Janicklas Ralph"},"license":"MIT","dependencies":{"querystring":"^0.2.0"},"repository":{"type":"git","url":"git+https://github.com/janicklas-ralph/native-url.git"},"bugs":{"url":"https://github.com/janicklas-ralph/native-url/issues"},"homepage":"https://github.com/janicklas-ralph/native-url#readme","keywords":["url","uri","normalization","normalisation","query","querystring","whatwg-url","parse","format","resolve","resolveObject"],"devDependencies":{"husky":"^3.0.5","jest":"^24.9.0","lint-staged":"^9.2.5","microbundle":"^0.11.0","prettier":"^1.18.2"},"lint-staged":{"linters":{"{src,tests}/**/*.js":["prettier --write","git add"]}},"husky":{"hooks":{"pre-commit":"yarn run test && lint-staged"}},"_id":"native-url@0.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-bjS8Gn0r2ixhQ5oO9TCLfISblFFXYR8qNAoA+qfOWpwQ7EHjFoB1ZOu/nBFmD5W/Y+82kho3W5vopARsbFhRZA==","shasum":"ea1802d41ca6118e25bab68fe30ed80ed3d95bb9","tarball":"http://registry-npm.ywwl.com/native-url/download/native-url-0.1.0.tgz","fileCount":1,"unpackedSize":1233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdiTiKCRA9TVsSAnZWagAALlgP/jvtSZefsNh+pj3q49yA\nprTqpmy+kknQnM7nb2umyF4Rc6ozH8AKzQXVcn+Iwcxu8UqN9tudMjkJTR8I\nd58BKEW7XdFDL9dSolLQ2ajlmSn1Tts2bOOTj/CricU1ztvsgdsLLp+NN03f\np9rAOxKmK09SR+o+SMFmE2+jSVFPhI+mr6OHuRwClw97RjbGlzyVeaeKhcdR\n0RTCJqrmYldD68grwA9qbrlKJ/OoOW3shhehXXjKAHEXVGtLpAJAHzcm+686\nZkVQfzEUqKhzQivpbM5ee/L1e0X0hSBKByycAnfTW9KJQseLYBHt8ho+i4DH\nmkuKt+gT+8ZnyejQeoRx4hVWSe3yCG4JzxfAhsx3CNlfKKr2LiK5os4TCDO4\n9Vi3sDSILsInqPDVlY18xjGsxPHRko3yPW7akAKveh80y+CG9ly3jHou6QfA\nhKmKwPhJV7gqQeXve/8RHbldCjO14HTsbxrbk/lrLbrhbzgXj/SlW4FkNAKq\nrgsJOVRoDyIFrcr63fow7jtgUVz46q2kMjtfs4+A25nrg9g85k4I/EOl1seb\nF7UsbQDE+rneIDCVNFGjgXQic9TsDlXlEkYIAXqyir7JqE6I4IWgJ/Eqv1HK\n67xmubfhaLqqaG4EZBGZwtYSfNDTnlmDMZSkh/Yamt5Kl9fFvjnrO3oQ0TA+\nomU5\r\n=p6zH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGHHywh7kq19Y86o4SafnInuc4iCeWEgbRVuHUJ8p8+lAiAVPe8Y/dnW1ZA0N9p3U+1zJYo69HsLbr4sCw7lrggWCg=="}],"size":625,"noattachment":false,"key":"/native-url/-/native-url-0.1.0.tgz"},"maintainers":[{"name":"janicklas-ralph","email":"janicklasralph036@gmail.com"}],"_npmUser":{"name":"janicklas-ralph","email":"janicklasralph036@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/native-url_0.1.0_1569273994020_0.900176645945908"},"_hasShrinkwrap":false,"readme":"# native-url [![npm package version](https://badgen.net/npm/v/native-url)](https://npm.im/native-url) [![bundle size](https://badgen.net/bundlephobia/minzip/native-url)](https://bundlephobia.com/result?p=native-url) [![github license](https://badgen.net/github/license/GoogleChromeLabs/native-url)](https://github.com/GoogleChromeLabs/native-url/blob/master/LICENSE)\n\nA lightweight implementation of Node's [url](http://nodejs.org/api/url.html) interface atop the [URL API](https://developer.mozilla.org/en-US/docs/Web/API/URL). Use it instead of the `url` module to reduce your bundle size by around 7.5 kB.\n\nWeighs **1.6 kB gzipped**, works in Node.js 7+ and [all modern browsers](https://caniuse.com/#feat=mdn-api_url):\n\n![Chrome 32, Firefox 19, Safari 7, Edge 12, Opera 19](https://badges.herokuapp.com/browsers?googlechrome=32&firefox=19&safari=7&microsoftedge=12&opera=19)\n\nOlder browsers can be [easily polyfilled](#polyfill-for-older-browsers) without new browsers loading the code.\n\n## Installation\n\n```sh\nnpm i native-url\n```\n\n## Usage\n\n```js\nconst url = require('native-url');\n\nurl.parse('https://example.com').host; // example.com\nurl.parse('/?a=b', true).query; // { a: 'b' }\n```\n\n### Usage with Webpack\n\nWhen you use the `url` module, webpack bundles [`node-url`](https://github.com/defunctzombie/node-url) for the browser. You can alias webpack to use `native-url` instead, saving around 7.5kB:\n\n```js\n// webpack.config.js\nmodule.exports = {\n  // ...\n  resolve: {\n    alias: {\n      url: 'native-url',\n    },\n  },\n};\n```\n\nThe result is **functionally equivalent** in Node 7+ and all modern browsers.\n\n### Usage with Rollup\n\nRollup does not bundle shims for Node.js modules like `url` by default, but we can add `url` support via `native-url` using aliases:\n\n```js\n// rollup.config.js\nimport resolve from 'rollup-plugin-node-resolve';\nimport alias from '@rollup/plugin-alias';\n\nmodule.exports = {\n  // ...\n  plugins: [\n    resolve(),\n    alias({\n      entries: {\n        url: 'native-url',\n      },\n    }),\n  ],\n};\n```\n\nWith this in place, `import url from 'url'` will use `native-url` and keep your bundle small.\n\n## API\n\nRefer Node's [legacy url documentation](https://nodejs.org/api/url.html#url_legacy_url_api) for detailed API documentation.\n\n### `url.parse(urlStr, [parseQueryString], [slashesDenoteHost])`\n\nParses a URL string and returns a URL object representation:\n\n```js\nurl.parse('https://example.com');\n// {\n//   href: 'http://example.com/',\n//   protocol: 'http:',\n//   slashes: true,\n//   host: 'example.com',\n//   hostname: 'example.com',\n//   query: {},\n//   search: null,\n//   pathname: '/',\n//   path: '/'\n// }\n\nurl.parse('/foo?a=b', true).query.a; // \"b\"\n```\n\n### `url.format(urlObj)`\n\nGiven a parsed URL object, returns its corresponding URL string representation:\n\n```js\nurl.format({ protocol: 'https', host: 'example.com' });\n// \"https://example.com\"\n```\n\n### `url.resolve(from, to)`\n\nResolves a target URL based on the provided base URL:\n\n```js\nurl.resolve('/a/b', 'c');\n// \"/a/b/c\"\nurl.resolve('/a/b', '/c#d');\n// \"/c#d\"\n```\n\n## Polyfill for Older Browsers\n\n`native-url` relies on the DOM [URL API](https://developer.mozilla.org/en-US/docs/Web/API/URL) to work. For older browsers that don't support the `URL` API, a [polyfill](https://www.npmjs.com/package/url-polyfill) is available.\n\nConveniently, a polyfill is never needed for [browsers that support ES Modules](https://caniuse.com/#feat=es6-module), so we can use `<script nomodule>` to conditionally load it for older browsers:\n\n```html\n<script nomodule src=\"/path/to/url-polyfill.js\"></script>\n```\n","publish_time":1569273994444,"_cnpm_publish_time":1569273994444,"dist-tags":{"latest":"0.3.4"}}