multiaddr-to-uri

Convert a Multiaddr to a URI /dnsaddr/ipfs.io/http -> http://ipfs.io

This module is deprecated, please upgrade to @multiformats/multiaddr-to-uri
Last updated 5 years ago by alanshaw .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install multiaddr-to-uri 
SYNC missed versions from official npm registry.

multiaddr-to-uri

Build Status dependencies Status JavaScript Style Guide

Convert a Multiaddr to a URI /dnsaddr/ipfs.io/http -> http://ipfs.io

Install

npm install multiaddr-to-uri

Usage

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:

  • When /tcp is the last (terminating) protocol HTTP is assumed by default (implicit assumeHttp: true)
    • this means produced URIs will start with http:// instead of tcp://
    • passing { assumeHttp: false } disables this behavior
  • Might be lossy - e.g. a DNSv6 multiaddr
  • Can throw if the passed multiaddr:
    • is not a valid multiaddr
    • is not supported as a URI e.g. circuit

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw

Current Tags

  • 8.0.0                                ...           latest (3 years ago)

9 Versions

  • 8.0.0 [deprecated]           ...           3 years ago
  • 7.0.0 [deprecated]           ...           4 years ago
  • 6.0.0 [deprecated]           ...           4 years ago
  • 5.1.0 [deprecated]           ...           5 years ago
  • 5.0.0 [deprecated]           ...           5 years ago
  • 4.0.1 [deprecated]           ...           6 years ago
  • 4.0.0 [deprecated]           ...           6 years ago
  • 3.0.0 [deprecated]           ...           7 years ago
  • 2.0.0 [deprecated]           ...           7 years ago
Maintainers (1)
Downloads
Total 7
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE