code review

This commit is contained in:
gorhill 2015-02-23 23:25:14 -05:00
parent c7bab5502e
commit aa6e0d563d
1 changed files with 19 additions and 18 deletions

View File

@ -571,27 +571,28 @@ FilterContainer.prototype.compile = function(s, out) {
var i = hostnames.length; var i = hostnames.length;
if ( i === 0 ) { if ( i === 0 ) {
this.compileGenericSelector(parsed, out); this.compileGenericSelector(parsed, out);
} else { return true;
// https://github.com/gorhill/uBlock/issues/151 }
// Negated hostname means the filter applies to all non-negated hostnames
// of same filter OR globally if there is no non-negated hostnames. // https://github.com/gorhill/uBlock/issues/151
var applyGlobally = true; // Negated hostname means the filter applies to all non-negated hostnames
var hostname; // of same filter OR globally if there is no non-negated hostnames.
while ( i-- ) { var applyGlobally = true;
hostname = hostnames[i]; var hostname;
if ( hostname.charAt(0) !== '~' ) { while ( i-- ) {
applyGlobally = false; hostname = hostnames[i];
} if ( hostname.charAt(0) !== '~' ) {
if ( hostname.slice(-2) === '.*' ) { applyGlobally = false;
this.compileEntitySelector(hostname, parsed, out);
} else {
this.compileHostnameSelector(hostname, parsed, out);
}
} }
if ( applyGlobally ) { if ( hostname.slice(-2) === '.*' ) {
this.compileGenericSelector(parsed, out); this.compileEntitySelector(hostname, parsed, out);
} else {
this.compileHostnameSelector(hostname, parsed, out);
} }
} }
if ( applyGlobally ) {
this.compileGenericSelector(parsed, out);
}
return true; return true;
}; };