Skip to content

Commit

Permalink
fix: return Unmapped range error from lookupPretty
Browse files Browse the repository at this point in the history
Fixes test by ensuring that lookupPretty callsback with the same
Unmapped range error as lookup does for local addresses.

WIP on ipfs-shipyard#65

License: MIT
Signed-off-by: Oli Evans <oli@tableflip.io>
  • Loading branch information
olizilla committed Jan 2, 2019
1 parent a39c43c commit f3f045a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pretty.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function isLocal (address) {
}

module.exports = function lookupPretty (ipfs, multiaddrs, cb) {
console.log('lookupPretty', multiaddrs.length, multiaddrs)
if (multiaddrs.length === 0) {
return cb(new Error('lookup requires a multiaddr array with length > 0'), null)
}
Expand All @@ -25,7 +26,11 @@ module.exports = function lookupPretty (ipfs, multiaddrs, cb) {

// No ip6 support at the moment
if (isLocal(address) || current[1] === 'ip6') {
return lookupPretty(ipfs, multiaddrs.slice(1), cb)
const next = multiaddrs.slice(1)
if (next.length > 0 ) {
return lookupPretty(ipfs, multiaddrs.slice(1), cb)
}
return cb(new Error('Unmapped range'), null)
}

lookup(ipfs, address, (err, res) => {
Expand Down

0 comments on commit f3f045a

Please sign in to comment.