tough-cookie 5.1.0-rc.0 → 5.1.0
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/dist/cookie/canonicalDomain.js +10 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.canonicalDomain = canonicalDomain;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes a domain to lowercase and punycode-encoded.
|
|
7
|
+
* Runtime-agnostic equivalent to node's `domainToASCII`.
|
|
8
|
+
* @see https://nodejs.org/docs/latest-v22.x/api/url.html#urldomaintoasciidomain
|
|
9
|
+
*/
|
|
10
|
+
function domainToASCII(domain) {
|
|
11
|
+
return new URL(`http://${domain}`).hostname;
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
14
|
* Transforms a domain name into a canonical domain name. The canonical domain name is a domain name
|
|
8
15
|
* that has been trimmed, lowercased, stripped of leading dot, and optionally punycode-encoded
|
|
@@ -46,12 +53,12 @@ function canonicalDomain(domainName) {
|
|
|
46
53
|
if (!str.endsWith(']')) {
|
|
47
54
|
str = str + ']';
|
|
48
55
|
}
|
|
49
|
-
return
|
|
56
|
+
return domainToASCII(str).slice(1, -1); // remove [ and ]
|
|
50
57
|
}
|
|
51
58
|
// convert to IDN if any non-ASCII characters
|
|
52
59
|
// eslint-disable-next-line no-control-regex
|
|
53
60
|
if (/[^\u0001-\u007f]/.test(str)) {
|
|
54
|
-
return
|
|
61
|
+
return domainToASCII(str);
|
|
55
62
|
}
|
|
56
63
|
// ASCII-only domain - not canonicalized with new URL() because it may be a malformed URL
|
|
57
64
|
return str.toLowerCase();
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED