uri-to-multiaddr

Convert a URI to a Multiaddr: https://multiformats.io -> /dns4/multiformats.io/tcp/443/https

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

uri-to-multiaddr

Build Status dependencies Status JavaScript Style Guide

Convert a URI to a Multiaddr: https://multiformats.io -> /dns4/multiformats.io/tcp/443/https

Install

npm install uri-to-multiaddr

Usage

const toMultiaddr = require('uri-to-multiaddr')

console.log(toMultiaddr('https://protocol.ai'))
// -> /dns4/protocol.ai/tcp/443/https

Domain names can represent one of

  • /dns4 - domain resolves to an ipv4 address (default)
  • /dns6 - domain resolves to an ipv6 address
  • /dnsaddr - domain has a DNSLink TXT record pointing to an IPFS CID

This library assumes /dns4 when it finds a domain name in the input string. It makes no attempt query DNS. To override the default assumption, you can pass in an options object as the second parameter to override it:

const toMultiaddr = require('uri-to-multiaddr')

console.log(toMultiaddr('https://protocol.ai'), { defaultDnsType: 'dns6' })
// -> /dns6/protocol.ai/tcp/443/https

See test.js for the currently supported conversions.

Note: uri-to-multiaddr will throw if the passed URI:

  • is not a valid, according the WHATWG URL spec implementation used.
  • is not supported yet

Related

Contribute

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

License

MIT © TABLEFLIP

Current Tags

  • 6.0.0                                ...           latest (3 years ago)

8 Versions

  • 6.0.0 [deprecated]           ...           3 years ago
  • 5.0.0 [deprecated]           ...           4 years ago
  • 4.0.0 [deprecated]           ...           4 years ago
  • 3.0.2 [deprecated]           ...           5 years ago
  • 3.0.1 [deprecated]           ...           6 years ago
  • 3.0.0 [deprecated]           ...           6 years ago
  • 2.0.0 [deprecated]           ...           6 years ago
  • 1.0.0 [deprecated]           ...           6 years ago
Downloads
Total 8
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (2)

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