GithubHelp home page GithubHelp logo

isabella232 / js-uri-to-multiaddr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from multiformats/js-uri-to-multiaddr

0.0 0.0 0.0 337 KB

Convert a URI to a Multiaddr: https://protocol.ai -> /dns4/protocol.ai/tcp/443/https

License: MIT License

JavaScript 100.00%

js-uri-to-multiaddr's Introduction

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

js-uri-to-multiaddr's People

Contributors

achingbrain avatar alanshaw avatar dependabot[bot] avatar lidel avatar olizilla avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.