From d92ea20acfbf2b01f409e8629ef952491140fc1f Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 8 Apr 2015 16:00:04 -0600 Subject: [PATCH] Fix #1212: less aggressive document blocking --- src/js/traffic.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/js/traffic.js b/src/js/traffic.js index 8129f9445..1ae1991f8 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -256,13 +256,6 @@ var toBlockDocResult = function(url, hostname, result) { return ''; } - // Quick test: if the result starts with `|` or `||`, then this means the - // match is before the path part of the URL for sure. - // Examples: sb:|http:// sb:||example.com^ - if ( result.charAt(3) === '|' ) { - return result; - } - // Make a regex out of the result var reText = result.slice(3); var pos = reText.indexOf('$'); @@ -270,11 +263,6 @@ var toBlockDocResult = function(url, hostname, result) { reText = reText.slice(0, pos); } - // Matches whole URL - if ( reText === '*' ) { - return result; - } - // We are going to have to take the long way to find out if ( reText.charAt(0) === '/' && reText.slice(-1) === '/' ) { reText = reText.slice(1, -1); @@ -295,8 +283,8 @@ var toBlockDocResult = function(url, hostname, result) { return ''; } - // verify that the match starts before the path - if ( matches.index < url.indexOf(hostname) + hostname.length ) { + // make sure the match ends before the path-part of the URL (#1212) + if ( re.lastIndex <= url.indexOf(hostname) + hostname.length + 1 ) { return result; }