Convert a Multiaddr to a URI /dnsaddr/ipfs.io/http -> http://ipfs.io
$ npm install multiaddr-to-uri
Convert a Multiaddr to a URI /dnsaddr/ipfs.io/http -> http://ipfs.io
npm install multiaddr-to-uri
const toUri = require('multiaddr-to-uri')
console.log(toUri('/dnsaddr/protocol.ai/https'))
// -> https://protocol.ai
console.log(toUri('/ip4/127.0.0.1/tcp/8080'))
// -> http://127.0.0.1:8080
console.log(toUri('/ip4/127.0.0.1/tcp/8080', { assumeHttp: false }))
// -> tcp://127.0.0.1:8080
Note:
/tcp
is the last (terminating) protocol HTTP is assumed by default (implicit assumeHttp: true
)
http://
instead of tcp://
{ assumeHttp: false }
disables this behaviorFeel free to dive in! Open an issue or submit PRs.
MIT © Alan Shaw
© 2010 - cnpmjs.org x YWFE | Home | YWFE