| Index: lib/filterClasses.js |
| =================================================================== |
| --- a/lib/filterClasses.js |
| +++ b/lib/filterClasses.js |
| @@ -719,37 +719,36 @@ |
| this.thirdParty = thirdParty; |
| if (sitekeys != null) |
| this.sitekeySource = sitekeys; |
| if (rewrite != null) |
| this.rewrite = rewrite; |
| if (resourceName) |
| this.resourceName = resourceName; |
| + if (!this.matchCase) |
| + regexpSource = regexpSource.toLowerCase(); |
| + |
| if (regexpSource.length >= 2 && |
| regexpSource[0] == "/" && |
| regexpSource[regexpSource.length - 1] == "/") |
| { |
| // The filter is a regular expression - convert it immediately to |
| // catch syntax errors |
| - let regexp = new RegExp(regexpSource.substring(1, regexpSource.length - 1), |
| - this.matchCase ? "" : "i"); |
| + let regexp = new RegExp(regexpSource.substring(1, regexpSource.length - 1)); |
| Object.defineProperty(this, "regexp", {value: regexp}); |
| } |
| else |
| { |
| // Patterns like /foo/bar/* exist so that they are not treated as regular |
| // expressions. We drop any superfluous wildcards here so our optimizations |
| // can kick in. |
| if (this.rewrite == null || this.resourceName) |
| regexpSource = regexpSource.replace(/^\*+/, "").replace(/\*+$/, ""); |
| - if (!this.matchCase && isLiteralPattern(regexpSource)) |
| - regexpSource = regexpSource.toLowerCase(); |
| - |
| // No need to convert this filter to regular expression yet, do it on demand |
| this.pattern = regexpSource; |
| } |
| } |
| exports.RegExpFilter = RegExpFilter; |
| RegExpFilter.prototype = extend(ActiveFilter, { |
| /** |
| @@ -776,20 +775,17 @@ |
| * @type {RegExp} |
| */ |
| get regexp() |
| { |
| let value = null; |
| let {pattern, rewrite, resourceName} = this; |
| if ((rewrite != null && !resourceName) || !isLiteralPattern(pattern)) |
| - { |
| - value = new RegExp(filterToRegExp(pattern, rewrite != null), |
| - this.matchCase ? "" : "i"); |
| - } |
| + value = new RegExp(filterToRegExp(pattern, rewrite != null)); |
| Object.defineProperty(this, "regexp", {value}); |
| return value; |
| }, |
| /** |
| * Content types the filter applies to, combination of values from |
| * RegExpFilter.typeMap |
| * @type {number} |
| @@ -893,24 +889,24 @@ |
| * @param {string} location The URL to check. |
| * @param {?string} [lowerCaseLocation] The lower-case version of the URL to |
| * check, for case-insensitive matching. |
| * @returns {boolean} <code>true</code> if the URL matches. |
| * @package |
| */ |
| matchesLocation(location, lowerCaseLocation) |
| { |
| + if (!this.matchCase) |
| + location = lowerCaseLocation || location.toLowerCase(); |
| + |
| let {regexp} = this; |
| if (regexp) |
| return regexp.test(location); |
| - if (!this.matchCase) |
| - location = lowerCaseLocation || location.toLowerCase(); |
| - |
| let {pattern} = this; |
| let startsWithDoubleAnchor = pattern[0] == "|" && pattern[1] == "|"; |
| let endsWithSeparator = pattern[pattern.length - 1] == "^"; |
| if (startsWithDoubleAnchor) |
| pattern = pattern.substr(2); |