Skip to content

Commit 63cd03e

Browse files
olizilladaviddias
authored andcommitted
fix: return Unmapped range error from lookupPretty
Fixes test by ensuring that lookupPretty callsback with the same Unmapped range error as lookup does for local addresses. WIP on #65 License: MIT Signed-off-by: Oli Evans <oli@tableflip.io>
1 parent a39c43c commit 63cd03e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pretty.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function isLocal (address) {
1212
}
1313

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

2627
// No ip6 support at the moment
2728
if (isLocal(address) || current[1] === 'ip6') {
28-
return lookupPretty(ipfs, multiaddrs.slice(1), cb)
29+
const next = multiaddrs.slice(1)
30+
if (next.length > 0 ) {
31+
return lookupPretty(ipfs, multiaddrs.slice(1), cb)
32+
}
33+
return cb(new Error('Unmapped range'), null)
2934
}
3035

3136
lookup(ipfs, address, (err, res) => {

0 commit comments

Comments
 (0)