1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-01 16:33:06 +01:00

code review (#3208)

This commit is contained in:
gorhill 2017-11-09 15:46:25 -05:00
parent f7bfcff37a
commit bc036724c1
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -304,8 +304,9 @@ 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; }
@ -313,14 +314,8 @@ var toBlockDocResult = function(url, hostname, logData) {
// 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);
};
/******************************************************************************/