Closed aksuska closed 1 year ago
Milestone: Someday. Label: #new. What's next? A reviewer should examine this issue.
Good catch, please make a pull request with these changes along with some new unit test cases. We want this to behave the Cocoa way.
-#new +Foundation +#needs-patch +#accepted
Milestone: Someday. Labels: #accepted, #needs-patch, Foundation. What's next? This issue needs a volunteer to write and submit code to address it.
According to lines 320-322 of CPComparisonPredicate, when the "like" operator is used, the framework uses RegExp.test() for comparison. However, because the expression is unanchored, the behavior is as if the "CONTAINS" operator was used but with wildcard support, and this is not how Cocoa works. The easiest solution is to anchor the expression, i.e. prepend a "^" and append a "$". Note also that the flags ate incorrect--"g" should never be used for tis kind of operator. The corrected code could look like:
This is my workaround and works properly.