Skip to content

Commit 858cc82

Browse files
authored
fix: decoding bracketed arrays (#252)
1 parent 1eaf0fb commit 858cc82

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/ini.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ const decode = (str, opt = {}) => {
140140
duplicates[keyRaw] = (duplicates?.[keyRaw] || 0) + 1
141141
isArray = duplicates[keyRaw] > 1
142142
}
143-
const key = isArray ? keyRaw.slice(0, -2) : keyRaw
143+
const key = isArray && keyRaw.endsWith('[]')
144+
? keyRaw.slice(0, -2) : keyRaw
145+
144146
if (key === '__proto__') {
145147
continue
146148
}

tap-snapshots/test/duplicate-properties.js.test.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Null Object {
1111
"three",
1212
],
1313
"ar[]": "one",
14-
"b": Array [
14+
"brr": Array [
15+
"1",
1516
"2",
1617
"3",
1718
"3",
1819
],
19-
"brr": "1",
2020
"str": "3",
2121
"zr": "123",
2222
"zr[]": "deedee",

0 commit comments

Comments
 (0)