Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -492,22 +492,26 @@ |
let source = this.regexpSource.replace(/\*+/g, "*"); |
// Remove leading wildcards |
- if (source[0] == "*") |
+ let hasLeadingWildcard = (source[0] == "*"); |
+ if (hasLeadingWildcard) |
source = source.substr(1); |
// Remove trailing wildcards |
let pos = source.length - 1; |
- if (pos >= 0 && source[pos] == "*") |
+ let hasTrailingWildcard = (pos >= 0 && source[pos] == "*"); |
+ if (hasTrailingWildcard) |
source = source.substr(0, pos); |
- source = source.replace(/\^\|$/, "^") // remove anchors following separator placeholder |
- .replace(/\W/g, "\\$&") // escape special symbols |
- .replace(/\\\*/g, ".*") // replace wildcards by .* |
- // process separator placeholders (all ANSI charaters but alphanumeric characters and _%.-) |
- .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\x60\\x7B-\\x80]|$)") |
- .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^.\\/]+\\.)*?") // process extended anchor at expression start |
- .replace(/^\\\|/, "^") // process anchor at expression start |
- .replace(/\\\|$/, "$"); // process anchor at expression end |
+ source = source.replace(/\^\|$/, "^") // remove anchors following separator placeholder |
+ .replace(/\W/g, "\\$&") // escape special symbols |
+ .replace(/\\\*/g, ".*") // replace wildcards by .* |
+ // process separator placeholders (all ANSI characters but alphanumeric characters and _%.-) |
+ .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\x60\\x7B-\\x7F]|$)"); |
+ if (!hasLeadingWildcard) |
+ source = source.replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^.\\/]+\\.)*?") // process extended anchor at expression start |
+ .replace(/^\\\|/, "^"); // process anchor at expression start |
+ if (!hasTrailingWildcard) |
+ source = source.replace(/\\\|$/, "$"); // process anchor at expression end |
Wladimir Palant
2014/01/24 13:11:32
This issue was introduced in the speedup here: htt
Thomas Greiner
2014/01/24 14:48:16
Done. If we still want to optimize the performance
|
let regexp = new RegExp(source, this.matchCase ? "" : "i"); |