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

Unified Diff: lib/url.js

Issue 29991594: Issue 7243 - Update adblockpluscore dependency to hg:e26e122e0702 (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Remove third-party checks from QUnit tests Created Jan. 31, 2019, 12:56 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') | lib/whitelisting.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/url.js
===================================================================
--- a/lib/url.js
+++ b/lib/url.js
@@ -14,18 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
/** @module url */
"use strict";
-const {getDomain} = require("./tldjs");
-
/**
* Gets the IDN-decoded hostname from the URL of a frame.
* If the URL don't have host information (like "about:blank"
* and "data:" URLs) it falls back to the parent frame.
*
* @param {?Frame} frame
* @param {URL} [originUrl]
* @return {string}
@@ -36,40 +34,8 @@
{
let {hostname} = frame.url;
if (hostname)
return hostname;
}
return originUrl ? originUrl.hostname : "";
};
-
-function isDomain(hostname)
-{
- // No hostname or IPv4 address, also considering hexadecimal octets.
- if (/^((0x[\da-f]+|\d+)(\.|$))*$/i.test(hostname))
- return false;
-
- // IPv6 address. Since there can't be colons in domains, we can
- // just check whether there are any colons to exclude IPv6 addresses.
- return hostname.indexOf(":") == -1;
-}
-
-/**
- * Checks whether the request's origin is different from the document's origin.
- *
- * @param {URL} url The request URL
- * @param {string} documentHost The IDN-decoded hostname of the document
- * @return {Boolean}
- */
-exports.isThirdParty = (url, documentHost) =>
-{
- let requestHost = url.hostname.replace(/\.+$/, "");
- documentHost = documentHost.replace(/\.+$/, "");
-
- if (requestHost == documentHost)
- return false;
-
- if (!isDomain(requestHost) || !isDomain(documentHost))
- return true;
-
- return getDomain(requestHost) != getDomain(documentHost);
-};
« no previous file with comments | « lib/tldjs.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld