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

Unified Diff: lib/url.js

Issue 30009560: Noissue - Rename lib/domain.js to lib/url.js (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 16, 2019, 12:42 p.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/matcher.js ('k') | test/url.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/url.js
===================================================================
rename from lib/domain.js
rename to lib/url.js
--- a/lib/domain.js
+++ b/lib/url.js
@@ -59,31 +59,31 @@
* <code>com</code>, in that order.
*
* @param {string} domain The domain.
* @param {boolean} [includeBlank] Whether to include the blank suffix at the
* end.
*
* @yields {string} The next suffix for the domain.
*/
-function* suffixes(domain, includeBlank = false)
+function* domainSuffixes(domain, includeBlank = false)
{
while (domain != "")
{
yield domain;
let dotIndex = domain.indexOf(".");
domain = dotIndex == -1 ? "" : domain.substr(dotIndex + 1);
}
if (includeBlank)
yield "";
}
-exports.suffixes = suffixes;
+exports.domainSuffixes = domainSuffixes;
/**
* Checks whether the given hostname is a domain.
*
* @param {string} hostname
* @returns {boolean}
*/
function isDomain(hostname)
@@ -98,22 +98,22 @@
}
/**
* Gets the base domain for the given hostname.
*
* @param {string} hostname
* @returns {string}
*/
-function getDomain(hostname)
+function getBaseDomain(hostname)
{
let slices = [];
let cutoff = NaN;
- for (let suffix of suffixes(hostname))
+ for (let suffix of domainSuffixes(hostname))
{
slices.push(suffix);
let offset = publicSuffixMap.get(suffix);
if (typeof offset != "undefined")
{
cutoff = slices.length - 1 - offset;
@@ -125,17 +125,17 @@
return slices.length > 2 ? slices[slices.length - 2] : hostname;
if (cutoff <= 0)
return hostname;
return slices[cutoff];
}
-exports.getDomain = getDomain;
+exports.getBaseDomain = getBaseDomain;
/**
* Checks whether a request's origin is different from its document's origin.
*
* @param {URL} url The request URL.
* @param {string} documentHostname The IDNA-encoded hostname of the document.
*
* @returns {boolean}
@@ -151,12 +151,12 @@
documentHostname = documentHostname.replace(/\.+$/, "");
if (requestHostname == documentHostname)
return false;
if (!isDomain(requestHostname) || !isDomain(documentHostname))
return true;
- return getDomain(requestHostname) != getDomain(documentHostname);
+ return getBaseDomain(requestHostname) != getBaseDomain(documentHostname);
}
exports.isThirdParty = isThirdParty;
« no previous file with comments | « lib/matcher.js ('k') | test/url.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld