Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: residual space after section causes bad parsing #123

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
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
4 changes: 2 additions & 2 deletions lib/ini.js
Original file line number Diff line number Diff line change
@@ -69,8 +69,8 @@ const decode = str => {
const out = Object.create(null)
let p = out
let section = null
// section |key = value
const re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
// section |key = value
const re = /^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i
const lines = str.split(/[\r\n]+/g)

for (const line of lines) {
1 change: 1 addition & 0 deletions tap-snapshots/test/foo.js.test.cjs
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ Null Object {
"three",
"this is included",
],
"b": Null Object {},
"br": "warm",
"eq": "eq=eq",
"false": false,
3 changes: 3 additions & 0 deletions test/fixtures/foo.ini
Original file line number Diff line number Diff line change
@@ -69,6 +69,9 @@ j = "{ o: "p", a: { av: "a val", b: { c: { e: "this [value]" } } } }"
cr[] = four
cr[] = eight

; b section with a space after its title
[b]

; nested child without middle parent
; should create otherwise-empty a.b
[a.b.c]