@multiformats/multiaddr
Advanced tools
Comparing version 10.3.0 to 10.3.1
@@ -399,4 +399,11 @@ import * as codec from './codec.js'; | ||
const parts = this.toString().split('/').slice(1); | ||
let protocol = parts[2]; | ||
let port = parseInt(parts[3]); | ||
// default to https when protocol & port are omitted from DNS addrs | ||
if (DNS_CODES.includes(codes[0]) && protocol === 'p2p') { | ||
protocol = 'tcp'; | ||
port = 443; | ||
} | ||
if (parts.length < 4) { | ||
throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".'); | ||
throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".'); | ||
} | ||
@@ -406,3 +413,3 @@ else if (!IP_CODES.includes(codes[0]) && !DNS_CODES.includes(codes[0])) { | ||
} | ||
else if (parts[2] !== 'tcp' && parts[2] !== 'udp') { | ||
else if (protocol !== 'tcp' && protocol !== 'udp') { | ||
throw new Error(`no protocol with name: "'${names[1]}'". Must have a valid transport protocol: "{tcp, udp}".`); | ||
@@ -413,3 +420,3 @@ } | ||
address: parts[1], | ||
port: parseInt(parts[3]) // tcp or udp port | ||
port // tcp or udp port | ||
}; | ||
@@ -416,0 +423,0 @@ } |
{ | ||
"name": "@multiformats/multiaddr", | ||
"version": "10.3.0", | ||
"version": "10.3.1", | ||
"description": "multiaddr implementation (binary + string representation of network addresses)", | ||
@@ -153,2 +153,3 @@ "license": "Apache-2.0 OR MIT", | ||
"scripts": { | ||
"clean": "aegir clean", | ||
"lint": "aegir lint", | ||
@@ -177,3 +178,3 @@ "dep-check": "aegir dep-check", | ||
"aegir": "^37.4.5", | ||
"sinon": "^13.0.1", | ||
"sinon": "^14.0.0", | ||
"util": "^0.12.3" | ||
@@ -180,0 +181,0 @@ }, |
@@ -462,8 +462,16 @@ import * as codec from './codec.js' | ||
const parts = this.toString().split('/').slice(1) | ||
let protocol = parts[2] | ||
let port = parseInt(parts[3]) | ||
// default to https when protocol & port are omitted from DNS addrs | ||
if (DNS_CODES.includes(codes[0]) && protocol === 'p2p') { | ||
protocol = 'tcp' | ||
port = 443 | ||
} | ||
if (parts.length < 4) { | ||
throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".') | ||
throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".') | ||
} else if (!IP_CODES.includes(codes[0]) && !DNS_CODES.includes(codes[0])) { | ||
throw new Error(`no protocol with name: "'${names[0]}'". Must have a valid family name: "{ip4, ip6, dns, dns4, dns6, dnsaddr}".`) | ||
} else if (parts[2] !== 'tcp' && parts[2] !== 'udp') { | ||
} else if (protocol !== 'tcp' && protocol !== 'udp') { | ||
throw new Error(`no protocol with name: "'${names[1]}'". Must have a valid transport protocol: "{tcp, udp}".`) | ||
@@ -475,3 +483,3 @@ } | ||
address: parts[1], | ||
port: parseInt(parts[3]) // tcp or udp port | ||
port // tcp or udp port | ||
} | ||
@@ -478,0 +486,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
130474
2641