tough-cookie 4.1.1 → 4.1.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/lib/pubsuffix-psl.js +13 -10
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/pubsuffix-psl.js
CHANGED
|
@@ -40,22 +40,25 @@ const SPECIAL_USE_DOMAINS = [
|
|
|
40
40
|
"test"
|
|
41
41
|
];
|
|
42
42
|
|
|
43
|
+
const SPECIAL_TREATMENT_DOMAINS = ["localhost", "invalid"];
|
|
44
|
+
|
|
43
45
|
function getPublicSuffix(domain, options = {}) {
|
|
44
46
|
const domainParts = domain.split(".");
|
|
45
47
|
const topLevelDomain = domainParts[domainParts.length - 1];
|
|
46
48
|
const allowSpecialUseDomain = !!options.allowSpecialUseDomain;
|
|
47
49
|
const ignoreError = !!options.ignoreError;
|
|
48
50
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
if (allowSpecialUseDomain && SPECIAL_USE_DOMAINS.includes(topLevelDomain)) {
|
|
52
|
+
if (domainParts.length > 1) {
|
|
53
|
+
const secondLevelDomain = domainParts[domainParts.length - 2];
|
|
54
|
+
// In aforementioned example, the eTLD/pubSuf will be apple.localhost
|
|
55
|
+
return `${secondLevelDomain}.${topLevelDomain}`;
|
|
56
|
+
} else if (SPECIAL_TREATMENT_DOMAINS.includes(topLevelDomain)) {
|
|
57
|
+
// For a single word special use domain, e.g. 'localhost' or 'invalid', per RFC 6761,
|
|
58
|
+
// "Application software MAY recognize {localhost/invalid} names as special, or
|
|
59
|
+
// MAY pass them to name resolution APIs as they would for other domain names."
|
|
60
|
+
return `${topLevelDomain}`;
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
if (!ignoreError && SPECIAL_USE_DOMAINS.includes(topLevelDomain)) {
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
module.exports = '4.1.
|
|
2
|
+
module.exports = '4.1.2'
|