Skip to content

Commit 8e8055d

Browse files
committed
validating arguments and supporting get with undefined key
1 parent 174fff0 commit 8e8055d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module.exports = (store) => {
2626
callback = key
2727
key = undefined
2828
}
29+
if (!key) {
30+
key = undefined
31+
}
2932
store.get(configKey, (err, encodedValue) => {
3033
if (err) { return callback(err) }
3134

@@ -55,7 +58,14 @@ module.exports = (store) => {
5558
callback = value
5659
value = key
5760
key = undefined
61+
} else if (!key || typeof key !== 'string') {
62+
return callback(new Error('Invalid key type'))
5863
}
64+
65+
if (value === undefined || Buffer.isBuffer(value)) {
66+
return callback(new Error('Invalid value type'))
67+
}
68+
5969
setQueue.push({
6070
key: key,
6171
value: value

0 commit comments

Comments
 (0)