From a529713f46d8d20765857308f23d3f99ede6f5c1 Mon Sep 17 00:00:00 2001 From: Cameron Nemo Date: Tue, 23 Jul 2024 06:03:10 -0700 Subject: [PATCH] fix(util): do not consume leading slash (#13) --- hjson/src/util.rs | 2 +- hjson_tests/assets/comments_result.hjson | 2 ++ hjson_tests/assets/comments_result.json | 4 +++- hjson_tests/assets/comments_test.hjson | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hjson/src/util.rs b/hjson/src/util.rs index 50e942a..afebb4b 100644 --- a/hjson/src/util.rs +++ b/hjson/src/util.rs @@ -132,7 +132,7 @@ where self.eat_char(); } Some(_) => { - self.eat_char(); + return Ok(()); } None => return Err(self.error(ErrorCode::TrailingCharacters)), //todo } diff --git a/hjson_tests/assets/comments_result.hjson b/hjson_tests/assets/comments_result.hjson index a99ce23..5efc212 100644 --- a/hjson_tests/assets/comments_result.hjson +++ b/hjson_tests/assets/comments_result.hjson @@ -23,4 +23,6 @@ str1: 00 # part of the string str2: 00.0 // part of the string str3: 02 /* part of the string */ + /key: value + key2: /value2 } \ No newline at end of file diff --git a/hjson_tests/assets/comments_result.json b/hjson_tests/assets/comments_result.json index e247803..5b5888f 100644 --- a/hjson_tests/assets/comments_result.json +++ b/hjson_tests/assets/comments_result.json @@ -22,5 +22,7 @@ "null3": null, "str1": "00 # part of the string", "str2": "00.0 // part of the string", - "str3": "02 /* part of the string */" + "str3": "02 /* part of the string */", + "/key": "value", + "key2": "/value2" } \ No newline at end of file diff --git a/hjson_tests/assets/comments_test.hjson b/hjson_tests/assets/comments_test.hjson index 7f1dfdc..0d2a9db 100644 --- a/hjson_tests/assets/comments_test.hjson +++ b/hjson_tests/assets/comments_test.hjson @@ -45,4 +45,6 @@ styles str1: 00 # part of the string str2: 00.0 // part of the string str3: 02 /* part of the string */ + /key: value + key2: /value2 }