normalize-url 8.0.0 → 8.0.2
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.
- package/index.d.ts +4 -2
- package/index.js +5 -2
- package/package.json +4 -2
- package/readme.md +4 -16
package/index.d.ts
CHANGED
|
@@ -61,10 +61,10 @@ export type Options = {
|
|
|
61
61
|
|
|
62
62
|
@example
|
|
63
63
|
```
|
|
64
|
-
normalizeUrl('user:password@sindresorhus.com');
|
|
64
|
+
normalizeUrl('https://user:password@sindresorhus.com');
|
|
65
65
|
//=> 'https://sindresorhus.com'
|
|
66
66
|
|
|
67
|
-
normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
|
|
67
|
+
normalizeUrl('https://user:password@sindresorhus.com', {stripAuthentication: false});
|
|
68
68
|
//=> 'https://user:password@sindresorhus.com'
|
|
69
69
|
```
|
|
70
70
|
*/
|
|
@@ -285,6 +285,8 @@ export type Options = {
|
|
|
285
285
|
|
|
286
286
|
URLs with custom protocols are not normalized and just passed through by default. Supported protocols are: `https`, `http`, `file`, and `data`.
|
|
287
287
|
|
|
288
|
+
Human-friendly URLs with basic auth (for example, `user:password@sindresorhus.com`) are not handled because basic auth conflicts with custom protocols. [Basic auth URLs are also deprecated.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#access_using_credentials_in_the_url)
|
|
289
|
+
|
|
288
290
|
@param url - URL to normalize, including [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs).
|
|
289
291
|
|
|
290
292
|
@example
|
package/index.js
CHANGED
|
@@ -13,7 +13,10 @@ const supportedProtocols = new Set([
|
|
|
13
13
|
const hasCustomProtocol = urlString => {
|
|
14
14
|
try {
|
|
15
15
|
const {protocol} = new URL(urlString);
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
return protocol.endsWith(':')
|
|
18
|
+
&& !protocol.includes('.')
|
|
19
|
+
&& !supportedProtocols.has(protocol);
|
|
17
20
|
} catch {
|
|
18
21
|
return false;
|
|
19
22
|
}
|
|
@@ -178,7 +181,7 @@ export default function normalizeUrl(urlString, options) {
|
|
|
178
181
|
// Decode URI octets
|
|
179
182
|
if (urlObject.pathname) {
|
|
180
183
|
try {
|
|
181
|
-
urlObject.pathname = decodeURI(urlObject.pathname);
|
|
184
|
+
urlObject.pathname = decodeURI(urlObject.pathname).replace(/\\/g, '%5C');
|
|
182
185
|
} catch {}
|
|
183
186
|
}
|
|
184
187
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "normalize-url",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "Normalize a URL",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/normalize-url",
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
"types": "./index.d.ts",
|
|
16
16
|
"default": "./index.js"
|
|
17
17
|
},
|
|
18
|
+
"sideEffects": false,
|
|
18
19
|
"engines": {
|
|
19
20
|
"node": ">=14.16"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
|
-
"test": "xo && c8 ava && tsd"
|
|
23
|
+
"//test": "xo && c8 ava && tsd",
|
|
24
|
+
"test": "c8 ava && tsd"
|
|
23
25
|
},
|
|
24
26
|
"files": [
|
|
25
27
|
"index.js",
|
package/readme.md
CHANGED
|
@@ -12,8 +12,6 @@ Useful when you need to display, store, deduplicate, sort, compare, etc, URLs.
|
|
|
12
12
|
npm install normalize-url
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
*If you need Safari support, use version 4: `npm i normalize-url@4`*
|
|
16
|
-
|
|
17
15
|
## Usage
|
|
18
16
|
|
|
19
17
|
```js
|
|
@@ -32,6 +30,8 @@ normalizeUrl('//www.sindresorhus.com:80/../baz?b=bar&a=foo');
|
|
|
32
30
|
|
|
33
31
|
URLs with custom protocols are not normalized and just passed through by default. Supported protocols are: `https`, `http`, `file`, and `data`.
|
|
34
32
|
|
|
33
|
+
Human-friendly URLs with basic auth (for example, `user:password@sindresorhus.com`) are not handled because basic auth conflicts with custom protocols. [Basic auth URLs are also deprecated.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#access_using_credentials_in_the_url)
|
|
34
|
+
|
|
35
35
|
#### url
|
|
36
36
|
|
|
37
37
|
Type: `string`
|
|
@@ -103,10 +103,10 @@ Default: `true`
|
|
|
103
103
|
Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of the URL.
|
|
104
104
|
|
|
105
105
|
```js
|
|
106
|
-
normalizeUrl('user:password@sindresorhus.com');
|
|
106
|
+
normalizeUrl('https://user:password@sindresorhus.com');
|
|
107
107
|
//=> 'https://sindresorhus.com'
|
|
108
108
|
|
|
109
|
-
normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
|
|
109
|
+
normalizeUrl('https://user:password@sindresorhus.com', {stripAuthentication: false});
|
|
110
110
|
//=> 'https://user:password@sindresorhus.com'
|
|
111
111
|
```
|
|
112
112
|
|
|
@@ -310,15 +310,3 @@ normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
|
|
|
310
310
|
## Related
|
|
311
311
|
|
|
312
312
|
- [compare-urls](https://github.com/sindresorhus/compare-urls) - Compare URLs by first normalizing them
|
|
313
|
-
|
|
314
|
-
---
|
|
315
|
-
|
|
316
|
-
<div align="center">
|
|
317
|
-
<b>
|
|
318
|
-
<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>
|
|
319
|
-
</b>
|
|
320
|
-
<br>
|
|
321
|
-
<sub>
|
|
322
|
-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
323
|
-
</sub>
|
|
324
|
-
</div>
|