From fa3b4c887c6f5b3bd27901b3de3c41c56cea25e0 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 9 Jun 2015 11:48:13 -0400 Subject: [PATCH] code review: result can be non-blocking yet non-empty --- src/js/pagestore.js | 4 ++-- src/js/static-net-filtering.js | 6 +++--- src/js/tab.js | 2 +- src/js/traffic.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 3d6d4a531..0b332a604 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -526,7 +526,7 @@ PageStore.prototype.filterRequest = function(context) { // Static filtering never override dynamic filtering if ( result === '' || result.charAt(1) === 'n' ) { - if ( µb.staticNetFilteringEngine.matchString(context) ) { + if ( µb.staticNetFilteringEngine.matchString(context) !== undefined ) { result = µb.staticNetFilteringEngine.toResultString(µb.logger.isEnabled()); } } @@ -568,7 +568,7 @@ PageStore.prototype.filterRequestNoCache = function(context) { // Static filtering never override dynamic filtering if ( result === '' || result.charAt(1) === 'n' ) { - if ( µb.staticNetFilteringEngine.matchString(context) ) { + if ( µb.staticNetFilteringEngine.matchString(context) !== undefined ) { result = µb.staticNetFilteringEngine.toResultString(µb.logger.isEnabled()); } } diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 52f968b84..52c80e88a 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -2238,7 +2238,7 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r // Be prepared to support unknown types var type = typeNameToTypeValue[requestType] || 0; if ( type === 0 ) { - return false; + return undefined; } var categories = this.categories; @@ -2280,7 +2280,7 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r // If there is no block filter, no need to test against allow filters if ( this.fRegister === null ) { - return false; + return undefined; } // Test against allow filters @@ -2412,7 +2412,7 @@ FilterContainer.prototype.matchString = function(context) { // If there is no block filter, no need to test against allow filters if ( this.fRegister === null ) { - return false; + return undefined; } // Test against allow filters diff --git a/src/js/tab.js b/src/js/tab.js index c195bbbb0..1c28b5007 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -507,7 +507,7 @@ vAPI.tabs.onPopup = function(details) { µb.getNetFilteringSwitch(openerURL) && µb.getNetFilteringSwitch(targetURL) ) { - if ( µb.staticNetFilteringEngine.matchStringExactType(context, targetURL, 'popup') ) { + if ( µb.staticNetFilteringEngine.matchStringExactType(context, targetURL, 'popup') !== undefined ) { result = µb.staticNetFilteringEngine.toResultString(loggerEnabled); } } diff --git a/src/js/traffic.js b/src/js/traffic.js index 0a458f0d8..f5db33fb1 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -185,7 +185,7 @@ var onBeforeRootFrameRequest = function(details) { // Filtering if ( result === '' ) { - if ( µb.staticNetFilteringEngine.matchString(context) ) { + if ( µb.staticNetFilteringEngine.matchString(context) !== undefined ) { // We always need the long-form result here. result = µb.staticNetFilteringEngine.toResultString(true); // https://github.com/chrisaljoudi/uBlock/issues/1128