Skip to content

Commit

Permalink
Fixed: Ignore optional commas in aggregate options (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
drigz authored and dcodeIO committed Mar 18, 2018
1 parent 07c5d59 commit c05c58f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions tests/comp_options-textformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ 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) {
var root = protobuf.parse(proto).root;
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();
});

0 comments on commit c05c58f

Please sign in to comment.