$ npm install @multiformats/multiaddr-to-uri
Convert a Multiaddr to a URI
This module allows easy conversion of Multiaddrs to string URIs.
import { multiaddrToUri } from '@multiformats/multiaddr-to-uri'
console.log(multiaddrToUri('/dnsaddr/protocol.ai/https'))
// -> https://protocol.ai
console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080'))
// -> http://127.0.0.1:8080
console.log(multiaddrToUri('/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 behavior$ npm i @multiformats/multiaddr-to-uri
<script>
tagLoading this module through a script tag will make it's exports available as MultiformatsMultiaddrToUri
in the global namespace.
<script src="https://unpkg.com/@multiformats/multiaddr-to-uri/dist/index.min.js"></script>
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
© 2010 - cnpmjs.org x YWFE | Home | YWFE