feat: adding support for ports in resolvable addresses

This commit is contained in:
dmitriy ryajov 2017-03-22 02:16:06 -07:00
parent 95c5922596
commit a1f9ccd457
2 changed files with 10 additions and 2 deletions

View File

@ -7,7 +7,7 @@ const multiaddr = require('multiaddr')
*/ */
const DNS4 = base('dns4') const DNS4 = base('dns4')
const DNS6 = base('dns6') const DNS6 = base('dns6')
const DNS = or( const _DNS = or(
base('dns'), base('dns'),
DNS4, DNS4,
DNS6 DNS6
@ -18,6 +18,11 @@ const TCP = and(IP, base('tcp'))
const UDP = and(IP, base('udp')) const UDP = and(IP, base('udp'))
const UTP = and(UDP, base('utp')) const UTP = and(UDP, base('utp'))
const DNS = or(
and(_DNS, base('tcp')),
_DNS
)
const WebSockets = or( const WebSockets = or(
and(TCP, base('ws')), and(TCP, base('ws')),
and(DNS, base('ws')) and(DNS, base('ws'))

View File

@ -10,7 +10,10 @@ describe('multiaddr validation', function () {
'/dns/ipfs.io', '/dns/ipfs.io',
'/dns4/ipfs.io', '/dns4/ipfs.io',
'/dns4/libp2p.io', '/dns4/libp2p.io',
'/dns6/protocol.ai' '/dns6/protocol.ai',
'/dns4/protocol.ai/tcp/80',
'/dns6/protocol.ai/tcp/80',
'/dns/protocol.ai/tcp/80'
] ]
const badDNS = [ const badDNS = [