From ae25ad78906179e1448ff7d97957810e2be40206 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 7 Apr 2022 12:17:38 +1000 Subject: nop whitespace formatting change. - ran eglot-format using typescript-language-server on all js files in the repo except those under /hash_script/ - verify only whitespace changed: git diff --word-diff-regex=. 62d6a71 62d6a71~1 --- bg/ListManager.js | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'bg/ListManager.js') diff --git a/bg/ListManager.js b/bg/ListManager.js index 745e599..f712356 100644 --- a/bg/ListManager.js +++ b/bg/ListManager.js @@ -23,11 +23,11 @@ A class to manage whitelist/blacklist operations */ -let {ListStore} = require("../common/Storage"); +let { ListStore } = require("../common/Storage"); class ListManager { constructor(whitelist, blacklist, builtInHashes) { - this.lists = {whitelist, blacklist}; + this.lists = { whitelist, blacklist }; this.builtInHashes = new Set(builtInHashes); } @@ -49,13 +49,13 @@ class ListManager { Returns "blacklisted", "whitelisted" or defValue */ getStatus(key, defValue = "unknown") { - let {blacklist, whitelist} = this.lists; + let { blacklist, whitelist } = this.lists; let inline = ListStore.inlineItem(key); if (inline) { return blacklist.contains(inline) ? "blacklisted" : whitelist.contains(inline) ? "whitelisted" - : defValue; + : defValue; } let match = key.match(/\(([^)]+)\)(?=[^()]*$)/); @@ -65,38 +65,38 @@ class ListManager { return (blacklist.contains(url) || ListManager.siteMatch(site, blacklist) ? "blacklisted" : whitelist.contains(url) || ListManager.siteMatch(site, whitelist) - ? "whitelisted" : defValue + ? "whitelisted" : defValue ); } - let [hashItem, srcHash] = match; // (hash), hash - return blacklist.contains(hashItem) ? "blacklisted" - : this.builtInHashes.has(srcHash) || whitelist.contains(hashItem) + let [hashItem, srcHash] = match; // (hash), hash + return blacklist.contains(hashItem) ? "blacklisted" + : this.builtInHashes.has(srcHash) || whitelist.contains(hashItem) ? "whitelisted" - : defValue; - } + : defValue; + } - /* - Matches by whole site ("http://some.domain.com/*") supporting also - wildcarded subdomains ("https://*.domain.com/*"). - */ - static siteMatch(url, list) { - let site = ListStore.siteItem(url); + /* + Matches by whole site ("http://some.domain.com/*") supporting also + wildcarded subdomains ("https://*.domain.com/*"). + */ + static siteMatch(url, list) { + let site = ListStore.siteItem(url); + if (list.contains(site)) { + return site; + } + site = site.replace(/^([\w-]+:\/\/)?(\w)/, "$1*.$2"); + for (; ;) { if (list.contains(site)) { return site; } - site = site.replace(/^([\w-]+:\/\/)?(\w)/, "$1*.$2"); - for (;;) { - if (list.contains(site)) { - return site; - } - let oldKey = site; - site = site.replace(/(?:\*\.)*\w+(?=\.)/, "*"); - if (site === oldKey) { - return null; - } + let oldKey = site; + site = site.replace(/(?:\*\.)*\w+(?=\.)/, "*"); + if (site === oldKey) { + return null; } } + } } module.exports = { ListManager }; -- cgit v1.2.3