File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,16 @@ function deepAssignTableArray(
209
209
return Object . assign ( target , unflat ( keys , [ value ] ) ) ;
210
210
}
211
211
if ( Array . isArray ( currentValue ) ) {
212
- currentValue . push ( value ) ;
212
+ if ( table . keys . length === 1 ) {
213
+ currentValue . push ( value ) ;
214
+ } else {
215
+ const last = currentValue . at ( - 1 ) ;
216
+ deepAssign ( last , {
217
+ type : table . type ,
218
+ keys : table . keys . slice ( 1 ) ,
219
+ value : table . value ,
220
+ } ) ;
221
+ }
213
222
return target ;
214
223
}
215
224
if ( isObject ( currentValue ) ) {
Original file line number Diff line number Diff line change @@ -857,6 +857,20 @@ Deno.test({
857
857
} ,
858
858
} ) ;
859
859
860
+ Deno . test ( {
861
+ name : "parse() handles nested table arrays" ,
862
+ fn ( ) {
863
+ const content = `
864
+ [[table]]
865
+ foo = "foo"
866
+ [[table.children]]
867
+ bar = "bar"` ;
868
+
869
+ const expected = { table : [ { foo : "foo" , children : [ { bar : "bar" } ] } ] } ;
870
+ assertEquals ( parse ( content ) , expected ) ;
871
+ } ,
872
+ } ) ;
873
+
860
874
Deno . test ( {
861
875
name : "parse() doesn't pollute prototype with __proto__" ,
862
876
async fn ( ) {
You can’t perform that action at this time.
0 commit comments