normalize-url 7.0.2 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +6 -0
  2. package/package.json +6 -7
  3. package/readme.md +2 -2
package/index.js CHANGED
@@ -192,6 +192,7 @@ export default function normalizeUrl(urlString, options) {
192
192
 
193
193
  // Remove query unwanted parameters
194
194
  if (Array.isArray(options.removeQueryParameters)) {
195
+ // eslint-disable-next-line unicorn/no-useless-spread -- We are intentionally spreading to get a copy.
195
196
  for (const key of [...urlObject.searchParams.keys()]) {
196
197
  if (testParameter(key, options.removeQueryParameters)) {
197
198
  urlObject.searchParams.delete(key);
@@ -206,6 +207,11 @@ export default function normalizeUrl(urlString, options) {
206
207
  // Sort query parameters
207
208
  if (options.sortQueryParameters) {
208
209
  urlObject.searchParams.sort();
210
+
211
+ // Calling `.sort()` encodes the search parameters, so we need to decode them again.
212
+ try {
213
+ urlObject.search = decodeURIComponent(urlObject.search);
214
+ } catch {}
209
215
  }
210
216
 
211
217
  if (options.removeTrailingSlash) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "normalize-url",
3
- "version": "7.0.2",
3
+ "version": "7.0.3",
4
4
  "description": "Normalize a URL",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/normalize-url",
@@ -16,7 +16,7 @@
16
16
  "node": ">=12.20"
17
17
  },
18
18
  "scripts": {
19
- "test": "xo && c8 ava && tsd"
19
+ "test": "ava && tsd"
20
20
  },
21
21
  "files": [
22
22
  "index.js",
@@ -38,11 +38,10 @@
38
38
  "canonical"
39
39
  ],
40
40
  "devDependencies": {
41
- "ava": "^3.15.0",
42
- "c8": "^7.7.3",
43
- "tsd": "^0.17.0",
44
- "typescript": "^4.3.5",
45
- "xo": "^0.41.0"
41
+ "ava": "^4.0.1",
42
+ "c8": "^7.11.0",
43
+ "tsd": "^0.19.1",
44
+ "xo": "^0.47.0"
46
45
  },
47
46
  "c8": {
48
47
  "reporter": [
package/readme.md CHANGED
@@ -8,8 +8,8 @@ Useful when you need to display, store, deduplicate, sort, compare, etc, URLs.
8
8
 
9
9
  ## Install
10
10
 
11
- ```
12
- $ npm install normalize-url
11
+ ```sh
12
+ npm install normalize-url
13
13
  ```
14
14
 
15
15
  *If you need to use this in the browser, use version 4: `npm i normalize-url@4`*