@lodestar/utils 1.49.0-dev.b27f498c2c → 1.49.0-dev.cd9f3245c9
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/lib/url.d.ts +2 -0
- package/lib/url.d.ts.map +1 -1
- package/lib/url.js +8 -0
- package/lib/url.js.map +1 -1
- package/package.json +2 -2
- package/src/url.ts +10 -0
package/lib/url.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function isValidHttpUrl(urlStr: string): boolean;
|
|
2
2
|
/** Return whether a URL is HTTP(S) and contains only visible ASCII characters. */
|
|
3
3
|
export declare function isValidAsciiHttpUrl(urlStr: string): boolean;
|
|
4
|
+
/** Return the ASCII form of an HTTP(S) URL with its hostname in punycode, or null if it has none. */
|
|
5
|
+
export declare function toAsciiHttpUrl(urlStr: string): string | null;
|
|
4
6
|
/**
|
|
5
7
|
* Sanitize URL to prevent leaking user credentials in logs or metrics
|
|
6
8
|
*
|
package/lib/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAmBtD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAS3D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAmBtD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAS3D;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO5D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
package/lib/url.js
CHANGED
|
@@ -27,6 +27,14 @@ export function isValidAsciiHttpUrl(urlStr) {
|
|
|
27
27
|
}
|
|
28
28
|
return isValidHttpUrl(urlStr);
|
|
29
29
|
}
|
|
30
|
+
/** Return the ASCII form of an HTTP(S) URL with its hostname in punycode, or null if it has none. */
|
|
31
|
+
export function toAsciiHttpUrl(urlStr) {
|
|
32
|
+
if (!isValidHttpUrl(urlStr)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const asciiUrl = new URL(urlStr).href;
|
|
36
|
+
return isValidAsciiHttpUrl(asciiUrl) ? asciiUrl : null;
|
|
37
|
+
}
|
|
30
38
|
/**
|
|
31
39
|
* Sanitize URL to prevent leaking user credentials in logs or metrics
|
|
32
40
|
*
|
package/lib/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAEtB,gFAAgF;QAChF,6EAA6E;QAC7E,6EAA6E;QAC7E,EAAE;QACF,4EAA4E;QAC5E,EAAE;QACF,kFAAkF;QAClF,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC/D,CAAC;AAED,kFAAkF;AAClF,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,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,QAAQ,GAAG,IAAI,IAAI,QAAQ,GAAG,IAAI,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IACtC,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.49.0-dev.
|
|
14
|
+
"version": "1.49.0-dev.cd9f3245c9",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"beacon",
|
|
64
64
|
"blockchain"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "b5c09efa35dfac7e2c4ccf55b755925a41b3ef7b"
|
|
67
67
|
}
|
package/src/url.ts
CHANGED
|
@@ -31,6 +31,16 @@ export function isValidAsciiHttpUrl(urlStr: string): boolean {
|
|
|
31
31
|
return isValidHttpUrl(urlStr);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Return the ASCII form of an HTTP(S) URL with its hostname in punycode, or null if it has none. */
|
|
35
|
+
export function toAsciiHttpUrl(urlStr: string): string | null {
|
|
36
|
+
if (!isValidHttpUrl(urlStr)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const asciiUrl = new URL(urlStr).href;
|
|
41
|
+
return isValidAsciiHttpUrl(asciiUrl) ? asciiUrl : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
/**
|
|
35
45
|
* Sanitize URL to prevent leaking user credentials in logs or metrics
|
|
36
46
|
*
|