Skip to content

Commit

Permalink
code review (#3208)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 9, 2017
1 parent f7bfcff commit bc03672
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,18 @@ var onBeforeRootFrameRequest = function(details) {

// https://github.com/gorhill/uBlock/issues/3208
// Mind case insensitivity.

var toBlockDocResult = function(url, hostname, logData) {
if ( typeof logData.regex !== 'string' ) { return; }
if ( typeof logData.regex !== 'string' ) { return false; }
var re = new RegExp(logData.regex, 'i'),
match = re.exec(url.toLowerCase());
if ( match === null ) { return false; }

// https://github.com/chrisaljoudi/uBlock/issues/1128
// https://github.com/chrisaljoudi/uBlock/issues/1212
// Relax the rule: verify that the match is completely before the path part
if (
(match.index + match[0].length) <=
(url.indexOf(hostname) + hostname.length + 1)
) {
return true;
}

return false;
return (match.index + match[0].length) <=
(url.indexOf(hostname) + hostname.length + 1);
};

/******************************************************************************/
Expand Down

0 comments on commit bc03672

Please sign in to comment.