Skip to content

Commit

Permalink
pref: read value only when assigning in parse
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jan 31, 2022
1 parent 04be428 commit 009b3cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
==========

* pref: read value only when assigning in parse
* pref: remove unnecessary regexp in parse

0.4.1 / 2020-04-21
Expand Down
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ function parse(str, options) {
}

var key = pair.substring(0, index).trim()
var val = pair.substring(index + 1, pair.length).trim()

// quoted values
if ('"' == val[0]) {
val = val.slice(1, -1);
}

// only assign once
if (undefined == obj[key]) {
var val = pair.substring(index + 1, pair.length).trim()

// quoted values
if (val[0] === '"') {
val = val.slice(1, -1)
}

obj[key] = tryDecode(val, dec);
}
}
Expand Down

0 comments on commit 009b3cb

Please sign in to comment.