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.
@@ -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
- allowSpecialUseDomain &&
51
- domainParts.length > 1 &&
52
- SPECIAL_USE_DOMAINS.includes(topLevelDomain)
53
- ) {
54
- // If the right-most label in the name is a special-use domain (e.g. bananas.apple.localhost),
55
- // then don't use PSL. This is because most special-use domains are not listed on PSL.
56
- const secondLevelDomain = domainParts[domainParts.length - 2];
57
- // In aforementioned example, the eTLD/pubSuf will be apple.localhost
58
- return `${secondLevelDomain}.${topLevelDomain}`;
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.1'
2
+ module.exports = '4.1.2'
package/package.json CHANGED
@@ -67,7 +67,7 @@
67
67
  "RFC6265",
68
68
  "RFC2965"
69
69
  ],
70
- "version": "4.1.1",
70
+ "version": "4.1.2",
71
71
  "homepage": "https://github.com/salesforce/tough-cookie",
72
72
  "repository": {
73
73
  "type": "git",