Socket
Socket
Sign inDemoInstall

@multiformats/multiaddr-to-uri

Package Overview
Dependencies
25
Maintainers
10
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @multiformats/multiaddr-to-uri

Convert a Multiaddr to a URI


Version published
Weekly downloads
21K
decreased by-3.7%
Maintainers
10
Install size
1.18 MB
Created
Weekly downloads
 

Changelog

Source

10.0.1 (2024-02-05)

Trivial Changes

  • rename master to main (81d94e5)

Documentation

Readme

Source

@multiformats/multiaddr-to-uri

multiformats.io codecov CI

Convert a Multiaddr to a URI

About

This module allows easy conversion of Multiaddrs to string URIs.

Example - Converting 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:

  • 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

Install

$ npm i @multiformats/multiaddr-to-uri

Browser <script> tag

Loading 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>

API Docs

License

Licensed under either of

Contribution

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.

Keywords

FAQs

Last updated on 05 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc