code review: page's hostname, not request's hostname

This commit is contained in:
gorhill 2014-10-06 17:56:13 -04:00
parent 0400352b4f
commit 2a78d7fb99
1 changed files with 11 additions and 8 deletions

View File

@ -1752,6 +1752,9 @@ FilterContainer.prototype.dynamicFilterStateToOption = {
};
FilterContainer.prototype.matchDynamicFilters = function(hostname, requestType, firstParty) {
if ( typeof hostname !== 'string' || hostname === '' ) {
return '';
}
var party = firstParty ? FirstParty : ThirdParty;
if ( typeNameToTypeValue.hasOwnProperty(requestType) === false ) {
return '';
@ -1948,9 +1951,12 @@ FilterContainer.prototype.matchStringExactType = function(pageDetails, requestUR
FirstParty :
ThirdParty;
// This will be used by hostname-based filters
pageHostname = pageDetails.pageHostname || '';
// Evaluate dynamic filters first. "Block" dynamic filters are always
// "important", they override everything else.
var bf = this.matchDynamicFilters(requestHostname, requestType, party === FirstParty);
var bf = this.matchDynamicFilters(pageHostname, requestType, party === FirstParty);
if ( bf !== '' && bf.slice(0, 2) !== '@@' ) {
return bf;
}
@ -1959,9 +1965,6 @@ FilterContainer.prototype.matchStringExactType = function(pageDetails, requestUR
var categories = this.categories;
var buckets = this.buckets;
// This will be used by hostname-based filters
pageHostname = pageDetails.pageHostname || '';
// Tokenize only once
this.tokenize(url);
@ -2040,16 +2043,16 @@ FilterContainer.prototype.matchString = function(pageDetails, requestURL, reques
}
}
// This will be used by hostname-based filters
pageHostname = pageDetails.pageHostname || '';
// Evaluate dynamic filters first. "Block" dynamic filters are always
// "important", they override everything else.
var bf = this.matchDynamicFilters(requestHostname, requestType, party === FirstParty);
var bf = this.matchDynamicFilters(pageHostname, requestType, party === FirstParty);
if ( bf !== '' && bf.slice(0, 2) !== '@@' ) {
return bf;
}
// This will be used by hostname-based filters
pageHostname = pageDetails.pageHostname || '';
var type = typeNameToTypeValue[requestType];
var categories = this.categories;
var buckets = this.buckets;