File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ### 0.10.1
4+ - Fixed ignore whitespace after comparison value in filter expression
5+
36### 0.10.0
47- Fixed query/selector Filter Expression With Current Object
58- Fixed query/selector Filter Expression With Different Grouped Operators
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class QueryMatchFilter extends AbstractFilter
2828
2929 protected const MATCH_QUERY_OPERATORS = '
3030 (@\.(?<key>[^\s<>!=]+)|@\[[" \']?(?<keySquare>.*?)[" \']?\]|(?<node>@)|(%group(?<group>\d+)%))
31- (\s*(?<operator>==|=~|=|<>|!==|!=|>=|<=|>|<|in|!in|nin)\s*(?<comparisonValue>.+?(?=( &&|$|\|\||%))))?
31+ (\s*(?<operator>==|=~|=|<>|!==|!=|>=|<=|>|<|in|!in|nin)\s*(?<comparisonValue>.+?(?=\s*(?: &&|$|\|\||%))))?
3232 (\s*(?<logicalandor>&&|\|\|)\s*)?
3333 ' ;
3434
Original file line number Diff line number Diff line change @@ -324,6 +324,21 @@ public function testQueryMatchEquals(): void
324324 self ::assertEquals ('The Lord of the Rings ' , $ result [0 ]);
325325 }
326326
327+ /**
328+ * $..books[?(@.category=="fiction" && @.author == \'Evelyn Waugh\')].title'
329+ * Filter books that are in the "..." category and have an author equal to "..."
330+ *
331+ * @throws JSONPathException|JsonException
332+ */
333+ public function testQueryMatchWhitespaceIgnored (): void
334+ {
335+ // Additional spaces in filter string are intended to be there
336+ $ result = (new JSONPath ($ this ->getData ('example ' )))
337+ ->find ('$..books[?( @.category=="fiction" && @.author == \'Evelyn Waugh \' )].title ' );
338+
339+ self ::assertEquals ('Sword of Honour ' , $ result [0 ]);
340+ }
341+
327342 /**
328343 * $..books[?(@.author = 1)]
329344 * Filter books that have a title equal to "..."
You can’t perform that action at this time.
0 commit comments