make getDomains foolproof

fixes #172
This commit is contained in:
tophf 2017-08-26 07:57:52 +03:00
parent 7e5396a11d
commit 0d038c59bc

View File

@ -542,10 +542,10 @@ function cleanupCachedFilters({force = false} = {}) {
function getDomains(url) { function getDomains(url) {
if (url.indexOf('file:') === 0) { let d = /.*?:\/*([^/:]+)|$/.exec(url)[1];
if (!d || url.startsWith('file:')) {
return []; return [];
} }
let d = /.*?:\/*([^/:]+)/.exec(url)[1];
const domains = [d]; const domains = [d];
while (d.indexOf('.') !== -1) { while (d.indexOf('.') !== -1) {
d = d.substring(d.indexOf('.') + 1); d = d.substring(d.indexOf('.') + 1);