Skip to content

Commit 009b3cb

Browse files
committed
pref: read value only when assigning in parse
1 parent 04be428 commit 009b3cb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
unreleased
22
==========
33

4+
* pref: read value only when assigning in parse
45
* pref: remove unnecessary regexp in parse
56

67
0.4.1 / 2020-04-21

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ function parse(str, options) {
6565
}
6666

6767
var key = pair.substring(0, index).trim()
68-
var val = pair.substring(index + 1, pair.length).trim()
69-
70-
// quoted values
71-
if ('"' == val[0]) {
72-
val = val.slice(1, -1);
73-
}
7468

7569
// only assign once
7670
if (undefined == obj[key]) {
71+
var val = pair.substring(index + 1, pair.length).trim()
72+
73+
// quoted values
74+
if (val[0] === '"') {
75+
val = val.slice(1, -1)
76+
}
77+
7778
obj[key] = tryDecode(val, dec);
7879
}
7980
}

0 commit comments

Comments
 (0)