Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(config): support null values (0 or empty string) on get and set
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 23, 2016
1 parent 56904fd commit a3d98a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@
"joi": "^9.0.4",
"libp2p-ipfs": "^0.12.1",
"libp2p-ipfs-browser": "^0.12.1",
"lodash.get": "^4.4.1",
"lodash.has": "^4.5.2",
"lodash.set": "^4.3.1",
"lodash.sortby": "^4.6.1",
"mafmt": "^2.1.1",
"map-limit": "0.0.1",
"lodash.get": "^4.4.1",
"lodash.set": "^4.3.1",
"multiaddr": "^2.0.2",
"multihashes": "^0.2.2",
"path-exists": "^3.0.0",
Expand Down
11 changes: 6 additions & 5 deletions src/core/ipfs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const promisify = require('promisify-es6')
const _get = require('lodash.get')
const _has = require('lodash.has')
const _set = require('lodash.set')

module.exports = function config (self) {
Expand All @@ -24,11 +25,11 @@ module.exports = function config (self) {
if (err) {
return callback(err)
}
const value = _get(config, key, undefined)
if (!value) {
callback(new Error('Key does not exist in config'))
} else {
if (_has(config, key)) {
const value = _get(config, key, undefined)
callback(null, value)
} else {
callback(new Error('Key does not exist in config'))
}
})
}),
Expand All @@ -37,7 +38,7 @@ module.exports = function config (self) {
return callback(new Error('Invalid key type'))
}

if (!value || Buffer.isBuffer(value)) {
if (value === undefined || Buffer.isBuffer(value)) {
return callback(new Error('Invalid value type'))
}

Expand Down

0 comments on commit a3d98a8

Please sign in to comment.