index.js
function multiaddrFromUri (uriStr, opts) {
  opts = opts || {}
  const defaultDnsType = opts.defaultDnsType || 'dns4'
  const { scheme, hostname, port } = parseUri(uriStr)
  const parts = [
    tupleForHostname(hostname, defaultDnsType),
    tupleForPort(port, scheme),
    tupleForScheme(scheme)
  ]
  const multiaddrStr = '/' + parts
    .filter(x => !!x)
    .reduce((a, b) => a.concat(b))
    .join('/')

  return Multiaddr(multiaddrStr)
}
function multiaddrFromUri (uriStr, opts) {
  opts = opts || {}
  const defaultDnsType = opts.defaultDnsType || 'dns4'
  const { scheme, hostname, port } = parseUri(uriStr)
  const parts = [
    tupleForHostname(hostname, defaultDnsType),
    tupleForPort(port, scheme),
    tupleForScheme(scheme)
  ]
  const multiaddrStr = '/' + parts
    .filter(x => !!x)
    .reduce((a, b) => a.concat(b))
    .join('/')

  return Multiaddr(multiaddrStr)
}
function multiaddrFromUri ( uriStr , opts ) { opts = opts || { } const defaultDnsType = opts . defaultDnsType || 'dns4' const { scheme , hostname , port } = parseUri ( uriStr ) const parts = [ tupleForHostname ( hostname , defaultDnsType ) , tupleForPort ( port , scheme ) , tupleForScheme ( scheme ) ] const multiaddrStr = '/' + parts . filter ( x => ! ! x ) . reduce ( ( a , b ) => a . concat ( b ) ) . join ( '/' ) return Multiaddr ( multiaddrStr ) }
Convert a URI to a multiaddr

http://foobar.com => /dns4/foobar.com/tcp/80/http
https://foobar.com => /dns4/foobar.com/tcp/443/https
https://foobar.com:5001 => /dns4/foobar.com/tcp/5001/https
https://127.0.0.1:8080 => /ip4/127.0.0.1/tcp/8080/https
http://[::1]:8080 => /ip6/::1/tcp/8080/http
tcp://foobar.com:8080 => /dns4/foobar.com/tcp/8080
udp://foobar.com:8080 => /dns4/foobar.com/udp/8080
Convert a URI to a multiaddr