Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow for an optional semicolon where there is an optional comma in parseOptionValue #1571

Merged
merged 4 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"no-self-compare": 1,
"no-throw-literal": 1,
"no-unmodified-loop-condition": 1,
"no-unused-expressions": 1,
"no-unused-expressions": ["error", { "allowShortCircuit": true }],
"no-useless-call": 1,
"no-useless-concat": 1,
"no-useless-escape": 1,
Expand Down
2 changes: 1 addition & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function parse(source, root, options) {
if (prevValue)
value = [].concat(prevValue).concat(value);
result[propName] = value;
skip(",", true);
skip(",", true) || skip(";", true);
}
return result;
}
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 @@ -15,6 +15,7 @@ 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\" }];\
string value4 = 4 [(my_options) = { a: \"foo\"; b: \"bar\" }];\
}";

tape.test("options in textformat", function(test) {
Expand All @@ -23,5 +24,6 @@ tape.test("options in textformat", function(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.same(Test.fields.value4.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly when semicolon-separated");
test.end();
});