From ec24044a9ea0072c00f41928757102d9fe4965bf Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 15 Aug 2018 10:33:42 +0100 Subject: [PATCH] fix: differentiate between invalid multihash and invalid CID License: MIT Signed-off-by: Alan Shaw --- src/core/components/object.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/components/object.js b/src/core/components/object.js index 58b21e5ca1..d83deae62a 100644 --- a/src/core/components/object.js +++ b/src/core/components/object.js @@ -221,6 +221,11 @@ module.exports = function object (self) { try { mh = normalizeMultihash(multihash, options.enc) + } catch (err) { + return setImmediate(() => callback(errCode(err, 'ERR_INVALID_MULTIHASH'))) + } + + try { cid = new CID(mh) } catch (err) { return setImmediate(() => callback(errCode(err, 'ERR_INVALID_CID')))