| Index: lib/url.js |
| diff --git a/lib/url.js b/lib/url.js |
| index 78a5f9599d4dd1404cdebda930e23539a97ad336..4ea741dbbfee3134f421426713b877edf6f39364 100644 |
| --- a/lib/url.js |
| +++ b/lib/url.js |
| @@ -17,6 +17,9 @@ |
| /** @module url */ |
| +let getDomain = require("tldjs").getDomain; |
| +let punycode = require("punycode"); |
| + |
| let getDecodedHostname = |
| /** |
| * Gets the IDN-decoded hostname from a URL object. |
| @@ -92,28 +95,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 +113,5 @@ exports.isThirdParty = function(url, documentHost) |
| if (!isDomain(requestHost) || !isDomain(documentHost)) |
| return true; |
| - return getBaseDomain(requestHost) != getBaseDomain(documentHost); |
| + return getDomain(requestHost) != getDomain(documentHost); |
| }; |