@multiformats/multiaddr
Advanced tools
Comparing version 10.4.2 to 10.4.3
@@ -95,3 +95,3 @@ import * as ip from './ip.js'; | ||
if (!ip.isIP(ipString)) { | ||
throw new Error('invalid ip address'); | ||
throw new Error(`invalid ip address "${ipString}"`); | ||
} | ||
@@ -98,0 +98,0 @@ return ip.toBytes(ipString); |
@@ -6,3 +6,3 @@ import { isIPv4, isIPv6 } from 'is-ip'; | ||
export declare const toBytes: (ip: string) => Uint8Array; | ||
export declare const toString: (buf: Uint8Array, offset: number, length: number) => string; | ||
export declare const toString: (buf: Uint8Array, offset?: number, length?: number) => string; | ||
//# sourceMappingURL=ip.d.ts.map |
@@ -11,2 +11,3 @@ import { isIPv4, isIPv6 } from 'is-ip'; | ||
let result; | ||
ip = ip.trim(); | ||
if (isV4(ip)) { | ||
@@ -57,3 +58,3 @@ result = new Uint8Array(offset + 4); | ||
if (result == null) { | ||
throw Error('Invalid ip address: ' + ip); | ||
throw new Error(`invalid ip address "${ip}"`); | ||
} | ||
@@ -63,3 +64,3 @@ return result; | ||
// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63 | ||
export const toString = function (buf, offset, length) { | ||
export const toString = function (buf, offset = 0, length) { | ||
offset = ~~offset; | ||
@@ -66,0 +67,0 @@ length = length ?? (buf.length - offset); |
{ | ||
"name": "@multiformats/multiaddr", | ||
"version": "10.4.2", | ||
"version": "10.4.3", | ||
"description": "multiaddr implementation (binary + string representation of network addresses)", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -106,3 +106,3 @@ | ||
if (!ip.isIP(ipString)) { | ||
throw new Error('invalid ip address') | ||
throw new Error(`invalid ip address "${ipString}"`) | ||
} | ||
@@ -109,0 +109,0 @@ return ip.toBytes(ipString) |
@@ -13,2 +13,3 @@ import { isIPv4, isIPv6 } from 'is-ip' | ||
let result | ||
ip = ip.trim() | ||
@@ -60,3 +61,3 @@ if (isV4(ip)) { | ||
if (result == null) { | ||
throw Error('Invalid ip address: ' + ip) | ||
throw new Error(`invalid ip address "${ip}"`) | ||
} | ||
@@ -68,3 +69,3 @@ | ||
// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63 | ||
export const toString = function (buf: Uint8Array, offset: number, length: number) { | ||
export const toString = function (buf: Uint8Array, offset: number = 0, length?: number) { | ||
offset = ~~offset | ||
@@ -71,0 +72,0 @@ length = length ?? (buf.length - offset) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
133181
2712