From c05c58fad61c16e5ce20ca19758e4782cdd5d2e3 Mon Sep 17 00:00:00 2001 From: Rodrigo Queiro Date: Sun, 18 Mar 2018 20:05:30 +0100 Subject: [PATCH] Fixed: Ignore optional commas in aggregate options (#999) --- src/parse.js | 1 + tests/comp_options-textformat.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/parse.js b/src/parse.js index ec26d982f..c0059ef24 100644 --- a/src/parse.js +++ b/src/parse.js @@ -567,6 +567,7 @@ function parse(source, root, options) { else setOption(parent, name + "." + token, readValue(true)); } + skip(",", true); } while (!skip("}", true)); } else setOption(parent, name, readValue(true)); diff --git a/tests/comp_options-textformat.js b/tests/comp_options-textformat.js index 62440b3be..b7788e48f 100644 --- a/tests/comp_options-textformat.js +++ b/tests/comp_options-textformat.js @@ -14,6 +14,7 @@ extend google.protobuf.FieldOptions {\ message Test {\ string value = 1 [(my_options) = { a: \"foo\" b: \"bar\" }];\ string value2 = 2 [(my_options) = { a: \"foo\" b { c: \"bar\" } }];\ + string value3 = 3 [(my_options) = { a: \"foo\", b: \"bar\" }];\ }"; tape.test("options in textformat", function(test) { @@ -21,5 +22,6 @@ tape.test("options in textformat", function(test) { var Test = root.lookup("Test"); test.same(Test.fields.value.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly"); test.same(Test.fields.value2.options, { "(my_options).a": "foo", "(my_options).b.c": "bar" }, "should parse correctly when nested"); + test.same(Test.fields.value3.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly when comma-separated"); test.end(); });