Skip to content

cityssm/is-private-network-address

Repository files navigation

is-private-network-address

npm (scoped) Code Climate maintainability DeepSource codecov Coverage Testing

Determines whether or not a network address is a private or internal.

Supports all Reserved IP Addresses used for private networks.

Installation

npm install @cityssm/is-private-network-address

Usage

import { isLocal, isPrivate } from "@cityssm/is-private-network-address";

/* Test Local IPs */

console.log(isLocal("127.0.0.1"));
// => true

console.log(isLocal("::1"));
// => true

console.log(isLocal("12.34.56.78"));
// => false

/* Test Private IPs */

console.log(isPrivate("10.0.100.100"));
// => true

console.log(isPrivate("192.168.2.1"));
// => true