Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/url.js

Issue 29340571: Issue 3687 - Add experimental support for Safari content blockers (Closed)
Patch Set: Addressed Nits Created May 18, 2016, 11:30 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/tldjs.js ('k') | metadata.chrome » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « lib/tldjs.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld