normalize-url
Advanced tools
Comparing version 6.0.1 to 6.1.0
@@ -158,4 +158,22 @@ declare namespace normalizeUrl { | ||
``` | ||
If a boolean is provided, `true` will remove all the query parameters. | ||
``` | ||
normalizeUrl('www.sindresorhus.com?foo=bar', { | ||
removeQueryParameters: true | ||
}); | ||
//=> 'http://sindresorhus.com' | ||
``` | ||
`false` will not remove any query parameter. | ||
``` | ||
normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', { | ||
removeQueryParameters: false | ||
}); | ||
//=> 'http://www.sindresorhus.com/?foo=bar&ref=test_ref&utm_medium=test' | ||
``` | ||
*/ | ||
readonly removeQueryParameters?: ReadonlyArray<RegExp | string>; | ||
readonly removeQueryParameters?: ReadonlyArray<RegExp | string> | boolean; | ||
@@ -162,0 +180,0 @@ /** |
@@ -176,2 +176,6 @@ 'use strict'; | ||
if (options.removeQueryParameters === true) { | ||
urlObj.search = ''; | ||
} | ||
// Sort query parameters | ||
@@ -178,0 +182,0 @@ if (options.sortQueryParameters) { |
{ | ||
"name": "normalize-url", | ||
"version": "6.0.1", | ||
"version": "6.1.0", | ||
"description": "Normalize a URL", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -178,3 +178,3 @@ # normalize-url [![Coverage Status](https://codecov.io/gh/sindresorhus/normalize-url/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/normalize-url) | ||
Type: `Array<RegExp | string>`\ | ||
Type: `Array<RegExp | string> | boolean`\ | ||
Default: `[/^utm_\w+/i]` | ||
@@ -191,2 +191,20 @@ | ||
If a boolean is provided, `true` will remove all the query parameters. | ||
```js | ||
normalizeUrl('www.sindresorhus.com?foo=bar', { | ||
removeQueryParameters: true | ||
}); | ||
//=> 'http://sindresorhus.com' | ||
``` | ||
`false` will not remove any query parameter. | ||
```js | ||
normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', { | ||
removeQueryParameters: false | ||
}); | ||
//=> 'http://www.sindresorhus.com/?foo=bar&ref=test_ref&utm_medium=test' | ||
``` | ||
##### removeTrailingSlash | ||
@@ -193,0 +211,0 @@ |
21244
373
287