Skip to content

Commit 869a95b

Browse files
Fix a bug in how unresolved features are preserved in options
1 parent b936af4 commit 869a95b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ function parse(source, root, options) {
657657
isOption = false;
658658
if (token.includes(".") && !token.includes("(")) {
659659
var tokens = token.split(".");
660-
option = tokens[0];
660+
option = tokens[0] + ".";
661661
token = tokens[1];
662662
continue;
663663
}

tests/feature_resolution_editions.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,29 @@ tape.test("feature resolution defaults", function(test) {
9292
test.end();
9393
})
9494

95+
tape.test("unresolved feature options", function(test) {
96+
var root = protobuf.parse(`edition = "2023";
97+
option features.json_format = LEGACY_BEST_EFFORT;
98+
option features.(abc).d_e = deeply_nested_false;
99+
100+
message Message {
101+
option features.enum_type = CLOSED;
102+
string string_val = 1;
103+
string string_repeated = 2;
104+
}`).root.resolveAll();
105+
106+
test.same(root.lookup("Message").options, {
107+
"features.enum_type": "CLOSED",
108+
});
109+
test.same(root.options, {
110+
"edition": "2023",
111+
"features.json_format": "LEGACY_BEST_EFFORT",
112+
"features.(abc).d_e": "deeply_nested_false",
113+
});
114+
115+
test.end();
116+
});
117+
95118
tape.test("feature resolution inheritance file to message", function(test) {
96119
var rootEditionsOverriden = protobuf.parse(`edition = "2023";
97120
option features.json_format = LEGACY_BEST_EFFORT;

0 commit comments

Comments
 (0)