diff options
author | Wojtek Kosior <koszko@koszko.org> | 2021-08-27 10:01:32 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2021-08-27 10:01:32 +0200 |
commit | 538376341e9a50ebd350897fe26f43c433f0ee06 (patch) | |
tree | fecea23bd499131f822d25e66b8b36819e6bb365 /common/settings_query.js | |
parent | 3303d7d70d4b9749c39ca87085d17495beab6030 (diff) | |
download | browser-extension-538376341e9a50ebd350897fe26f43c433f0ee06.tar.gz browser-extension-538376341e9a50ebd350897fe26f43c433f0ee06.zip |
enable whitelisting of `file://' protocol\n\nThis commit additionally also changes the semantics of triple asterisk wildcard in URL path.
Diffstat (limited to 'common/settings_query.js')
-rw-r--r-- | common/settings_query.js | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/common/settings_query.js b/common/settings_query.js index e85ae63..b54e580 100644 --- a/common/settings_query.js +++ b/common/settings_query.js @@ -8,30 +8,25 @@ /* * IMPORTS_START * IMPORT TYPE_PREFIX - * IMPORT for_each_possible_pattern + * IMPORT each_url_pattern * IMPORTS_END */ -function check_pattern(storage, pattern, multiple, matched) -{ - const settings = storage.get(TYPE_PREFIX.PAGE, pattern); - - if (settings === undefined) - return; - - matched.push([pattern, settings]); - - if (!multiple) - return false; -} - function query(storage, url, multiple) { const matched = []; const cb = p => check_pattern(storage, p, multiple, matched); - for_each_possible_pattern(url, cb); + for (const pattern of each_url_pattern(url)) { + const result = [pattern, storage.get(TYPE_PREFIX.PAGE, pattern)]; + if (result[1] === undefined) + continue; + + if (!multiple) + return result; + matched.push(result); + } - return multiple ? matched : (matched[0] || [undefined, undefined]); + return multiple ? matched : [undefined, undefined]; } function query_best(storage, url) |