From 0d038c59bc7505a82a691748f3d5369ef3f15c69 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 26 Aug 2017 07:57:52 +0300 Subject: [PATCH] make getDomains foolproof fixes #172 --- background/storage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/background/storage.js b/background/storage.js index 0fe28c29..c0e1ce3a 100644 --- a/background/storage.js +++ b/background/storage.js @@ -542,10 +542,10 @@ function cleanupCachedFilters({force = false} = {}) { function getDomains(url) { - if (url.indexOf('file:') === 0) { + let d = /.*?:\/*([^/:]+)|$/.exec(url)[1]; + if (!d || url.startsWith('file:')) { return []; } - let d = /.*?:\/*([^/:]+)/.exec(url)[1]; const domains = [d]; while (d.indexOf('.') !== -1) { d = d.substring(d.indexOf('.') + 1);