From 5af880790a637576d550620a14993979231ca454 Mon Sep 17 00:00:00 2001 From: Cameron Nemo Date: Sat, 7 Dec 2019 14:03:33 -0800 Subject: [PATCH] fix(util): do not consume leading slash Closes #12 --- hjson/src/util.rs | 2 +- hjson_tests/assets/comments_result.hjson | 4 +++- hjson_tests/assets/comments_result.json | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hjson/src/util.rs b/hjson/src/util.rs index 75a765d..0cecfa8 100644 --- a/hjson/src/util.rs +++ b/hjson/src/util.rs @@ -124,7 +124,7 @@ impl StringReader self.eat_char(); self.eat_char(); }, - Some(_) => { self.eat_char(); }, + Some(_) => { 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..c65e8b6 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 */ -} \ No newline at end of file + /key: value + key2: /value2 +} diff --git a/hjson_tests/assets/comments_result.json b/hjson_tests/assets/comments_result.json index e247803..ee815f5 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 */" -} \ No newline at end of file + "str3": "02 /* part of the string */", + "/key": "value", + "key2": "/value2" +}