Go to file
dependabot-preview[bot] 5406483888
chore(deps): [security] bump acorn from 7.1.0 to 7.4.0 (#42)
Bumps [acorn](https://github.com/acornjs/acorn) from 7.1.0 to 7.4.0. **This update includes security fixes.**
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/7.1.0...7.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-08-11 09:13:19 +01:00
.gitignore initial commit 2018-03-20 14:39:26 +00:00
.travis.yml chore: update deps (#45) 2020-08-11 09:04:05 +01:00
index.js feat: retain aliased protocols (#11) 2020-01-01 22:29:49 +00:00
LICENSE initial commit 2018-03-20 14:39:26 +00:00
package-lock.json chore(deps): bump lodash from 4.17.15 to 4.17.19 (#40) 2020-08-11 09:13:04 +01:00
package.json chore: update deps (#45) 2020-08-11 09:04:05 +01:00
README.md chore: update repo URL 2019-08-21 11:13:53 +01:00
test.js feat: retain aliased protocols (#11) 2020-01-01 22:29:49 +00:00

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