{"name":"normalize-url","version":"5.3.1","description":"Normalize a URL","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/normalize-url.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["normalize","url","uri","address","string","normalization","normalisation","query","querystring","simplify","strip","trim","canonical"],"devDependencies":{"ava":"^2.4.0","coveralls":"^3.0.6","nyc":"^15.0.0","tsd":"^0.11.0","xo":"^0.25.3"},"readme":"# normalize-url [![Build Status](https://travis-ci.org/sindresorhus/normalize-url.svg?branch=master)](https://travis-ci.org/sindresorhus/normalize-url) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/normalize-url/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/normalize-url?branch=master)\n\n> [Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL\n\nUseful when you need to display, store, deduplicate, sort, compare, etc, URLs.\n\n## Install\n\n```\n$ npm install normalize-url\n```\n\n*If you need to use this in the browser, use version 4: `npm i normalize-url@4`*\n\n## Usage\n\n```js\nconst normalizeUrl = require('normalize-url');\n\nnormalizeUrl('sindresorhus.com');\n//=> 'http://sindresorhus.com'\n\nnormalizeUrl('//www.sindresorhus.com:80/../baz?b=bar&a=foo');\n//=> 'http://sindresorhus.com/baz?a=foo&b=bar'\n```\n\n## API\n\n### normalizeUrl(url, options?)\n\n#### url\n\nType: `string`\n\nURL to normalize, including [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs).\n\n#### options\n\nType: `object`\n\n##### defaultProtocol\n\nType: `string`\\\nDefault: `http:`\n\n##### normalizeProtocol\n\nType: `boolean`\\\nDefault: `true`\n\nPrepend `defaultProtocol` to the URL if it's protocol-relative.\n\n```js\nnormalizeUrl('//sindresorhus.com:80/');\n//=> 'http://sindresorhus.com'\n\nnormalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});\n//=> '//sindresorhus.com'\n```\n\n##### forceHttp\n\nType: `boolean`\\\nDefault: `false`\n\nNormalize `https:` to `http:`.\n\n```js\nnormalizeUrl('https://sindresorhus.com:80/');\n//=> 'https://sindresorhus.com'\n\nnormalizeUrl('https://sindresorhus.com:80/', {forceHttp: true});\n//=> 'http://sindresorhus.com'\n```\n\n##### forceHttps\n\nType: `boolean`\\\nDefault: `false`\n\nNormalize `http:` to `https:`.\n\n```js\nnormalizeUrl('https://sindresorhus.com:80/');\n//=> 'https://sindresorhus.com'\n\nnormalizeUrl('http://sindresorhus.com:80/', {forceHttps: true});\n//=> 'https://sindresorhus.com'\n```\n\nThis option can't be used with the `forceHttp` option at the same time.\n\n##### stripAuthentication\n\nType: `boolean`\\\nDefault: `true`\n\nStrip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of the URL.\n\n```js\nnormalizeUrl('user:password@sindresorhus.com');\n//=> 'https://sindresorhus.com'\n\nnormalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});\n//=> 'https://user:password@sindresorhus.com'\n```\n\n##### stripHash\n\nType: `boolean`\\\nDefault: `false`\n\nStrip the hash part of the URL.\n\n```js\nnormalizeUrl('sindresorhus.com/about.html#contact');\n//=> 'http://sindresorhus.com/about.html#contact'\n\nnormalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});\n//=> 'http://sindresorhus.com/about.html'\n```\n\n##### stripProtocol\n\nType: `boolean`\\\nDefault: `false`\n\nRemove HTTP(S) protocol from the URL: `http://sindresorhus.com` → `sindresorhus.com`.\n\n```js\nnormalizeUrl('https://sindresorhus.com');\n//=> 'https://sindresorhus.com'\n\nnormalizeUrl('https://sindresorhus.com', {stripProtocol: true});\n//=> 'sindresorhus.com'\n```\n\n##### stripWWW\n\nType: `boolean`\\\nDefault: `true`\n\nRemove `www.` from the URL.\n\n```js\nnormalizeUrl('http://www.sindresorhus.com');\n//=> 'http://sindresorhus.com'\n\nnormalizeUrl('http://www.sindresorhus.com', {stripWWW: false});\n//=> 'http://www.sindresorhus.com'\n```\n\n##### removeQueryParameters\n\nType: `Array<RegExp | string>`\\\nDefault: `[/^utm_\\w+/i]`\n\nRemove query parameters that matches any of the provided strings or regexes.\n\n```js\nnormalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {\n\tremoveQueryParameters: ['ref']\n});\n//=> 'http://sindresorhus.com/?foo=bar'\n```\n\n##### removeTrailingSlash\n\nType: `boolean`\\\nDefault: `true`\n\nRemove trailing slash.\n\n**Note:** Trailing slash is always removed if the URL doesn't have a pathname unless the `removeSingleSlash` option is set to `false`.\n\n```js\nnormalizeUrl('http://sindresorhus.com/redirect/');\n//=> 'http://sindresorhus.com/redirect'\n\nnormalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});\n//=> 'http://sindresorhus.com/redirect/'\n\nnormalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});\n//=> 'http://sindresorhus.com'\n```\n\n##### removeSingleSlash\n\nType: `boolean`\\\nDefault: `true`\n\nRemove a sole `/` pathname in the output. This option is independant of `removeTrailingSlash`.\n\n```js\nnormalizeUrl('https://sindresorhus.com/');\n//=> 'https://sindresorhus.com'\n\nnormalizeUrl('https://sindresorhus.com/', {removeSingleSlash: false});\n//=> 'https://sindresorhus.com/'\n```\n\n\n##### removeDirectoryIndex\n\nType: `boolean | Array<RegExp | string>`\\\nDefault: `false`\n\nRemoves the default directory index file from path that matches any of the provided strings or regexes. When `true`, the regex `/^index\\.[a-z]+$/` is used.\n\n```js\nnormalizeUrl('www.sindresorhus.com/foo/default.php', {\n\tremoveDirectoryIndex: [/^default\\.[a-z]+$/]\n});\n//=> 'http://sindresorhus.com/foo'\n```\n\n##### sortQueryParameters\n\nType: `boolean`\\\nDefault: `true`\n\nSorts the query parameters alphabetically by key.\n\n```js\nnormalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {\n\tsortQueryParameters: false\n});\n//=> 'http://sindresorhus.com/?b=two&a=one&c=three'\n```\n\n## Related\n\n- [compare-urls](https://github.com/sindresorhus/compare-urls) - Compare URLs by first normalizing them\n\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-normalize-url?utm_source=npm-normalize-url&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","readmeFilename":"readme.md","gitHead":"42df4fe21c1ea0a58a273238159061d3267faa52","bugs":{"url":"https://github.com/sindresorhus/normalize-url/issues"},"homepage":"https://github.com/sindresorhus/normalize-url#readme","_id":"normalize-url@5.3.1","_nodeVersion":"12.22.1","_npmVersion":"7.5.4","dist":{"integrity":"sha512-K1c7+vaAP+Yh5bOGmA10PGPpp+6h7WZrl7GwqKhUflBc9flU9pzG27DDeB9+iuhZkE3BJZOcgN1P/2sS5pqrWw==","shasum":"c8485c0f5ba2f9c17a6d2907b56117ae5967f882","tarball":"http://registry-npm.ywwl.com/normalize-url/download/normalize-url-5.3.1.tgz","fileCount":5,"unpackedSize":18554,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgq6XMCRA9TVsSAnZWagAAdsQP/RJGe9V7SDtWmCw0tgWw\n2qG1vItyRrpP6jft4yJxll87r9PNtAvG3j7L+aJ+IqYlLaDhJiH7o884pEaj\nuYBAnJ9E1DCnIPuJep77beJODdljU5WxBjXwhvpC+H9ejYmwRREPUErzkzKM\nzhQtPdDqf+feqOEIsYqtSHTGecNcTIVIH0fz5yDbYlxKiY/9rsG2to8VP9Sl\njuuKme1MAcaEc/8mtCLeS16sdrs4jen1VKFHY/GXtxlNHZeExYris9WXIxpW\nYvE9MZvOZgcimO3oEoz7x+AfVSv1xc3PeYXGMoH7VJ5GjhQxRX57ruW6oGJH\ncyHWldr0aixqUbktYcC7ZGr3LtM0h5qFSTiIzic9OArAYZvcYrbTxYtSbaI4\nakwTXkcFpgETXcdKZRN2UIyZx+ubgTrjyKVcV90j4lPToyudBe4/SDggE5Go\n7GNk7vC4o1MD0XvCPSpxJmb+0/kYDl6EgxZ4qT4LWW0ddx7ik2ECZtPJRQZ6\n4x/gTEPCBHVQYrubTfMsLpJoWl56k+CoR5RmZdJM4h1fLsHrlzqBSb4t2Kgv\nfoHHd5K3IoZr15PgxCF0p9s5gSuu5sD+kKybYwT+toOnBvg3U0sC+hBVlgj1\nTc9dFG39jLf+L8Oi72RdrydT/9rEvWrhOxcyRCdQwEuw6xon4AWasLIU7pZj\nmJAc\r\n=vvES\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9a4qG+HGQbZheLY6utvT8pJY+3U/myG4nikNRXba0bgIhAPlHZq6avvYW5532PWdGpcOOEfvqbttqjlzLh5l49y4s"}],"size":5301,"noattachment":false,"key":"/normalize-url/-/normalize-url-5.3.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"},{"name":"kevva","email":"kevinmartensson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/normalize-url_5.3.1_1621861833420_0.7267886017779515"},"_hasShrinkwrap":false,"publish_time":1621861833569,"_cnpm_publish_time":1621861833569,"dist-tags":{"4-5-1":"4.5.1","5-3-1":"5.3.1","latest":"10.0.0"}}