Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filterClasses.js

Issue 4922123285954560: Fixed: Pipe in filter interpreted wrong when wildcards stripped away (Closed)
Patch Set: Created Jan. 24, 2014, 11:33 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld