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

Unified Diff: lib/domain.js

Issue 29999569: Noissue - Use suffixes function (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Remove misleading comment Created Feb. 6, 2019, 1:15 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 | « no previous file | lib/elemHide.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/domain.js
===================================================================
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -41,29 +41,37 @@
/**
* Yields all suffixes for a domain. For example, given the domain
* <code>www.example.com</code>, this function yields
* <code>www.example.com</code>, <code>example.com</code>, and
* <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)
+function* suffixes(domain, includeBlank = false)
{
while (domain != "")
{
yield domain;
let dotIndex = domain.indexOf(".");
domain = dotIndex == -1 ? "" : domain.substr(dotIndex + 1);
}
+
+ if (includeBlank)
+ yield "";
}
+exports.suffixes = suffixes;
+
/**
* Checks whether the given hostname is a domain.
*
* @param {string} hostname
* @returns {boolean}
*/
function isDomain(hostname)
{
« no previous file with comments | « no previous file | lib/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld