File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ function buf2str (buf) {
126
126
127
127
function mh2buf ( hash ) {
128
128
// the address is a varint prefixed multihash string representation
129
- const mh = bs58 . decode ( ( new CID ( hash ) ) . toString ( 'base58btc' ) )
129
+ const mh = new CID ( hash ) . multihash
130
130
const size = Buffer . from ( varint . encode ( mh . length ) )
131
131
return Buffer . concat ( [ size , mh ] )
132
132
}
Original file line number Diff line number Diff line change @@ -356,6 +356,13 @@ describe('variants', () => {
356
356
expect ( addr . toString ( ) ) . to . equal ( str )
357
357
} )
358
358
359
+ it ( 'p2p' , ( ) => {
360
+ const str = '/p2p/bafzbeidt255unskpefjmqb2rc27vjuyxopkxgaylxij6pw35hhys4vnyp4'
361
+ const addr = multiaddr ( str )
362
+ expect ( addr ) . to . have . property ( 'buffer' )
363
+ expect ( addr . toString ( ) ) . to . equal ( '/p2p/QmW8rAgaaA6sRydK1k6vonShQME47aDxaFidbtMevWs73t' )
364
+ } )
365
+
359
366
it ( 'ipfs' , ( ) => {
360
367
const str = '/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC'
361
368
const addr = multiaddr ( str )
You can’t perform that action at this time.
0 commit comments