Skip to content

normalizeIpAddress ​

normalizeIpAddress ​

Normalizes an IP address string for comparison.
IPv4 addresses pass through unchanged; IPv6 addresses expand to 8 colon-separated zero-padded groups.

ts
function normalizeIpAddress(
	value: string,
): string

Parameters

  • value: string — IPv4 or IPv6 address string to normalize.

Returns — The normalized address string.

Examples

ts
normalizeIpAddress('::1');
// '0000:0000:0000:0000:0000:0000:0000:0001'

Released under the MIT License.