Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit bb1a235

Browse files
authored
fix: dont compare empty strings (#330)
1 parent 866e5a6 commit bb1a235

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/transport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ function ourAddresses (peerInfo) {
236236
: `${addr}/ipfs/${ourPeerId}`
237237
return ourAddrs.concat([addr, otherAddr])
238238
}, [])
239+
.filter(a => Boolean(a))
239240
.concat(`/ipfs/${ourPeerId}`)
240241
}
241242

test/transport-manager.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ describe('Transport Manager', () => {
9595
expect(dialableAddrs[0].toString()).to.equal('/ip6/::1/tcp/4001')
9696
})
9797

98+
it('should filter out our addrs that start with /ipfs/', () => {
99+
const queryAddrs = [
100+
'/ip4/127.0.0.1/tcp/4002/ipfs/QmebzNV1kSzLfaYpSZdShuiABNUxoKT1vJmCdxM2iWsM2j'
101+
].map(a => Multiaddr(a))
102+
103+
const ourAddrs = [
104+
'/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
105+
]
106+
107+
ourAddrs.forEach(a => peerInfo.multiaddrs.add(a))
108+
109+
const dialableAddrs = TransportManager.dialables(dialAllTransport, queryAddrs, peerInfo)
110+
111+
expect(dialableAddrs).to.have.length(1)
112+
expect(dialableAddrs[0]).to.eql(queryAddrs[0])
113+
})
114+
98115
it('should filter our addresses over relay/rendezvous', () => {
99116
const peerId = peerInfo.id.toB58String()
100117
const queryAddrs = [

0 commit comments

Comments
 (0)