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

Commit

Permalink
fix: config handler should check if value is null (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov authored and richardschneider committed Dec 17, 2017
1 parent 21668e1 commit a93d4c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/http/api/resources/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ exports.getOrSet = {
const value = request.pre.args.value
const ipfs = request.server.app.ipfs

if (typeof value === 'object' &&
value.type === 'Buffer') {
// check that value exists - typeof null === 'object'
if (value && (typeof value === 'object' &&
value.type === 'Buffer')) {
return reply({
Message: 'Invalid value type',
Code: 0
Expand Down
6 changes: 6 additions & 0 deletions test/cli/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ describe('config', () => runOnAndOff((thing) => {
})
})

it('set a config key with null', () => {
return ipfs('config foo null --json').then((out) => {
expect(updatedConfig().foo).to.equal(null)
})
})

it('set a config key with json', () => {
return ipfs('config foo {"bar":0} --json').then((out) => {
expect(updatedConfig().foo).to.deep.equal({ bar: 0 })
Expand Down

0 comments on commit a93d4c0

Please sign in to comment.