From 2ae97cc53c71a2588e905f99abd6505b97904a20 Mon Sep 17 00:00:00 2001 From: jsen- Date: Tue, 21 Jun 2022 21:39:36 +0200 Subject: [PATCH 1/2] add new-lines to whitespace --- src/grammer.pest | 2 +- tests/filter.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/grammer.pest b/src/grammer.pest index 515102d..46666c4 100644 --- a/src/grammer.pest +++ b/src/grammer.pest @@ -69,4 +69,4 @@ query = _{SOI ~ "$" ~ root? ~ EOI} simple_query = _{SOI ~ "$" ~ simple_root ~ EOI} -WHITESPACE = _{ " " } \ No newline at end of file +WHITESPACE = _{ " " | "\r\n" | "\n" | "\r" | "\t" } \ No newline at end of file diff --git a/tests/filter.rs b/tests/filter.rs index 7758d67..dc8598c 100644 --- a/tests/filter.rs +++ b/tests/filter.rs @@ -319,3 +319,12 @@ fn unimplemented_in_filter() { json!([]), ); } + +#[test] +fn whitespace() { + select_and_then_compare( + "$\n[\r?\t(\r\n@\r.a == 1)]", + json!({"a": 1}), + json!([{"a" : 1}]), + ); +} From cd9d8336c2a1f7a32b0246819d5c217c17ef0b76 Mon Sep 17 00:00:00 2001 From: jsen- Date: Tue, 21 Jun 2022 22:30:50 +0200 Subject: [PATCH 2/2] impl std::error::Error for QueryCompilationError --- src/json_path.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/json_path.rs b/src/json_path.rs index fd07b22..d187749 100644 --- a/src/json_path.rs +++ b/src/json_path.rs @@ -21,6 +21,8 @@ pub struct QueryCompilationError { message: String, } +impl std::error::Error for QueryCompilationError {} + impl std::fmt::Display for QueryCompilationError { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!(