Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 12d7693

Browse files
committedJan 18, 2022
fix: residual space after section causes bad parsing
Any character left on a line after a section should be ignored.
1 parent 4f28994 commit 12d7693

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed
 

‎lib/ini.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ const decode = str => {
6363
const out = Object.create(null)
6464
let p = out
6565
let section = null
66-
// section |key = value
67-
const re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
66+
// section |key = value
67+
const re = /^\[([^\]]*)\].*$|^([^=]+)(=(.*))?$/i
6868
const lines = str.split(/[\r\n]+/g)
6969

7070
for (const line of lines) {

‎tap-snapshots/test/foo.js.test.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Null Object {
3535
"three",
3636
"this is included",
3737
],
38+
"b": Null Object {},
3839
"br": "warm",
3940
"eq": "eq=eq",
4041
"false": false,

‎test/fixtures/foo.ini

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ j = "{ o: "p", a: { av: "a val", b: { c: { e: "this [value]" } } } }"
6969
cr[] = four
7070
cr[] = eight
7171
72+
; b section with a space after its title
73+
[b]
74+
7275
; nested child without middle parent
7376
; should create otherwise-empty a.b
7477
[a.b.c]

0 commit comments

Comments
 (0)
Please sign in to comment.