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

Commit

Permalink
fix(http:object): proper handling of empty args
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 12, 2016
1 parent 6d82408 commit 9763f86
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/http-api/resources/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,21 @@ exports.patchAddLink = {
return reply("Arguments 'root', 'name' & 'ref' are required").code(400).takeover()
}

const error = (msg) => reply({
Message: msg,
Code: 0
}).code(500).takeover()

if (!request.query.arg[0]) {
return error('cannot create link with no root')
}

if (!request.query.arg[1]) {
return reply({
Message: 'cannot create link with no name!',
Code: 0
}).code(500).takeover()
return error('cannot create link with no name!')
}

if (!request.query.arg[2]) {
return error('cannot create link with no ref')
}

try {
Expand All @@ -366,10 +376,7 @@ exports.patchAddLink = {
})
} catch (err) {
log.error(err)
return reply({
Message: 'invalid ipfs ref path',
Code: 0
}).code(500).takeover()
return error('invalid ipfs ref path')
}
},

Expand Down

0 comments on commit 9763f86

Please sign in to comment.