Index: lib/url.js |
diff --git a/lib/url.js b/lib/url.js |
index 78a5f9599d4dd1404cdebda930e23539a97ad336..3a4d3bc485c420924bd76564d2d33aa2ade22477 100644 |
--- a/lib/url.js |
+++ b/lib/url.js |
@@ -17,6 +17,8 @@ |
/** @module url */ |
+let getDomain = require("tldjs").getDomain; |
+ |
let getDecodedHostname = |
/** |
* Gets the IDN-decoded hostname from a URL object. |
@@ -92,28 +94,6 @@ function isDomain(hostname) |
return hostname.indexOf(":") == -1; |
} |
-function getBaseDomain(hostname) |
-{ |
- let bits = hostname.split("."); |
- let cutoff = bits.length - 2; |
- |
- for (let i = 0; i < bits.length; i++) |
- { |
- let offset = publicSuffixes[bits.slice(i).join(".")]; |
- |
- if (typeof offset != "undefined") |
- { |
- cutoff = i - offset; |
- break; |
- } |
- } |
- |
- if (cutoff <= 0) |
- return hostname; |
- |
- return bits.slice(cutoff).join("."); |
-} |
- |
/** |
* Checks whether the request's origin is different from the document's origin. |
* |
@@ -132,5 +112,5 @@ exports.isThirdParty = function(url, documentHost) |
if (!isDomain(requestHost) || !isDomain(documentHost)) |
return true; |
- return getBaseDomain(requestHost) != getBaseDomain(documentHost); |
+ return getDomain(requestHost) != getDomain(documentHost); |
}; |