is-cidr

Check if a string is an IP address in CIDR notation

BSD-2-Clause 30 个版本
安装
npm install is-cidr
yarn add is-cidr
pnpm add is-cidr
bun add is-cidr
README

is-cidr

Check if a string is an IP address in CIDR notation

Install

npm i is-cidr

Usage

import isCidr from "is-cidr";

isCidr("192.168.0.1/24"); //=> 4
isCidr("1:2:3:4:5:6:7:8/64"); //=> 6
isCidr("10.0.0.0"); //=> 0
isCidr.v6("10.0.0.0/24"); //=> false

API

isCidr(input)

Check if input is a IPv4 or IPv6 CIDR. Returns either 4, 6 (indicating the IP version) or 0 if the string is not a CIDR.

isCidr.v4(input)

Check if input is a IPv4 CIDR. Returns a boolean.

isCidr.v6(input)

Check if input is a IPv6 CIDR. Returns a boolean.

  • ip-bigint - Convert IPv4 and IPv6 addresses to native BigInt and vice-versa
  • ip-regex - Regular expression for matching IP addresses
  • is-ip - Check if a string is an IP address
  • cidr-regex - Check if a string is an IP address in CIDR notation
  • cidr-tools - Tools to work with IPv4 and IPv6 CIDR network lists

License

© silverwind, distributed under BSD licence

Based on previous work by Felipe Apostol

版本列表
7.0.0 2026-05-07
6.0.4 2026-04-21
6.0.3 2026-02-09
6.0.2 2026-01-24
6.0.1 2025-09-23
6.0.0 2025-08-01
5.1.1 2025-02-14
5.1.0 2024-05-23
5.0.5 2024-04-09
5.0.4 2024-04-08
5.0.3 2023-03-30
5.0.2 2022-09-20
5.0.1 2022-09-19
5.0.0 2022-09-16
4.0.2 2020-09-28
4.0.1 2020-09-08
4.0.0 2020-05-13
3.1.1 2020-05-13
3.1.0 2019-08-23
3.0.0 2018-10-14
2.0.7 2018-09-18
2.0.6 2018-06-04
2.0.5 2018-03-03
2.0.4 2017-12-18
2.0.3 2017-12-18
2.0.2 2017-12-18
2.0.1 2017-12-18
2.0.0 2017-12-18
1.0.0 2016-03-25