[]previous and next page

normalizeIp

Normalizes an IP address: IPv4 stays as is, IPv6 is written in full lower-case groups, and an IPv4-mapped IPv6 address (::ffff:1.2.3.4) becomes the IPv4 address.

Normalizes an IP address: IPv4 stays as is, IPv6 is written in full lower-case groups, and an IPv4-mapped IPv6 address (::ffff:1.2.3.4) becomes the IPv4 address. Brackets and a port ([::1]:80, 1.2.3.4:80) are removed.

Import#

ts
import { normalizeIp } from "@shadow-js/dusk/server";

Signature#

ts
function normalizeIp(value: string): string | undefined

Parameters#

Name Description
value Text from a socket or a header.

Returns#

The normalized address, or undefined when value is not an IP address.

Examples#

ts
normalizeIp("::FFFF:10.0.0.1"); // "10.0.0.1"