Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
style: standard format
  • Loading branch information
wujunchuan committed Nov 28, 2020
commit 035c5810fdea741fa44b95b534c3937075edb3d0
6 changes: 3 additions & 3 deletions ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function decode (str) {
var bucket = {
'root': {}
}
var curSection = 'root';
var curSection = 'root'

lines.forEach(function (line, _, __) {
if (!line || line.match(/^\s*[;#]/)) return
Expand All @@ -88,14 +88,14 @@ function decode (str) {
section = unsafe(match[1])
p = out[section] = out[section] || {}
bucket[section] = bucket[section] || {}
curSection = section;
curSection = section
return
}
var key = unsafe(match[2])
var value = match[3] ? unsafe(match[4]) : true

var _keyWithoutArraySuffix = key.split('[]')[0]
var curBucket = bucket[curSection];
var curBucket = bucket[curSection]
curBucket[_keyWithoutArraySuffix] = curBucket[_keyWithoutArraySuffix] ? ++curBucket[_keyWithoutArraySuffix] : 1

if (curBucket[_keyWithoutArraySuffix] > 1) key = _keyWithoutArraySuffix + '[]'
Expand Down