mirror of
https://github.com/fluencelabs/js-multiaddr-to-uri
synced 2024-12-04 11:50:20 +00:00
ed39063659
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. **This update includes a security fix.** - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> |
||
---|---|---|
.gitignore | ||
.travis.yml | ||
index.js | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
README.md | ||
test.js |
multiaddr-to-uri
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 (implicitassumeHttp: true
)- this means produced URIs will start with
http://
instead oftcp://
- passing
{ assumeHttp: false }
disables this behavior
- this means produced URIs will start with
- 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