Skip to content

Commit

Permalink
shorten getRoot function
Browse files Browse the repository at this point in the history
  • Loading branch information
claustromaniac committed Jan 17, 2019
1 parent c225a02 commit 7c88fda
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/bg/webRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ const rIDs = {}; // tab objs by request ID
const getRoot = host => {
const parts = host.split('.');
let root;
let previous = '';
while (parts.length > 1) {
previous = root;
const previous = root;
root = parts.shift();
const suffix = parts.join('.');
if (publicSuffixes.has(suffix)) {
previous = null;
break;
}
if (publicSuffixes.has(suffix)) break;
if (publicSuffixes.has(`*.${suffix}`)) {
root = null;
root = previous;
break;
}
}
return root || previous;
return root;
};
const isExcluded = (origin, target) => {
const arr = settings.exclusions;
Expand All @@ -47,7 +43,7 @@ browser.webRequest.onBeforeSendHeaders.addListener(d => {
return;
}
if (
(d.method !== 'GET' && d.method !== 'OPTIONS') ||
(d.method !== 'GET' && d.method !== 'OPTIONS') ||
!settings.enabled
) return;
const info = tabs.getInfo(d.tabId);
Expand Down

0 comments on commit 7c88fda

Please sign in to comment.