Skip to content
Open
Show file tree
Hide file tree
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: 4 additions & 0 deletions lib/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ const safe = val => {

const unsafe = val => {
val = (val || '').trim()
const quotedValue = val.match(/^("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')\s*[;#]/)
if (quotedValue) {
val = quotedValue[1]
}
if (isQuoted(val)) {
// remove the single quotes before calling JSON.parse
if (val.charAt(0) === "'") {
Expand Down
10 changes: 10 additions & 0 deletions test/quoted-values.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const ini = require('../')
const tap = require('tap')

tap.test('quoted values with inline comments', t => {
t.same(ini.parse('a.b = "c" ; asdf'), { 'a.b': 'c' })
t.same(ini.parse("value = 'quoted' # comment"), { value: 'quoted' })
t.same(ini.parse('value = "semi;colon" ; comment'), { value: 'semi;colon' })
t.same(ini.parse('value = plain ; comment'), { value: 'plain' })
t.end()
})