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

fix: config handler should check if value is null #1134

Merged
merged 1 commit into from
Dec 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion test/utils/interop-daemon-spawner/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const os = require('os')
const crypto = require('libp2p-crypto')
const path = require('path')
const hat = require('hat')

Expand Down