Skip to content

Commit

Permalink
fix: decoding bracketed arrays (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherry authored May 22, 2024
1 parent 1eaf0fb commit 858cc82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ const decode = (str, opt = {}) => {
duplicates[keyRaw] = (duplicates?.[keyRaw] || 0) + 1
isArray = duplicates[keyRaw] > 1
}
const key = isArray ? keyRaw.slice(0, -2) : keyRaw
const key = isArray && keyRaw.endsWith('[]')
? keyRaw.slice(0, -2) : keyRaw

if (key === '__proto__') {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions tap-snapshots/test/duplicate-properties.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Null Object {
"three",
],
"ar[]": "one",
"b": Array [
"brr": Array [
"1",
"2",
"3",
"3",
],
"brr": "1",
"str": "3",
"zr": "123",
"zr[]": "deedee",
Expand Down

0 comments on commit 858cc82

Please sign in to comment.