Socket
Socket
Sign inDemoInstall

is-cidr

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-cidr

Check if a string is an IP address in CIDR notation


Version published
Weekly downloads
756K
increased by5%
Maintainers
1
Weekly downloads
 
Created

What is is-cidr?

The is-cidr npm package is a utility for validating and parsing CIDR (Classless Inter-Domain Routing) notations. It helps in determining whether a given string is a valid CIDR notation for IPv4 or IPv6 addresses.

What are is-cidr's main functionalities?

Validate IPv4 CIDR

This feature allows you to check if a given string is a valid IPv4 CIDR notation. The function returns true if the input is a valid IPv4 CIDR and false otherwise.

const isCidr = require('is-cidr');
console.log(isCidr.v4('192.168.0.1/24')); // true
console.log(isCidr.v4('192.168.0.1')); // false

Validate IPv6 CIDR

This feature allows you to check if a given string is a valid IPv6 CIDR notation. The function returns true if the input is a valid IPv6 CIDR and false otherwise.

const isCidr = require('is-cidr');
console.log(isCidr.v6('2001:db8::/32')); // true
console.log(isCidr.v6('2001:db8::')); // false

Validate both IPv4 and IPv6 CIDR

This feature allows you to check if a given string is a valid CIDR notation for either IPv4 or IPv6. The function returns 4 for valid IPv4 CIDR, 6 for valid IPv6 CIDR, and 0 for invalid CIDR.

const isCidr = require('is-cidr');
console.log(isCidr('192.168.0.1/24')); // 4
console.log(isCidr('2001:db8::/32')); // 6
console.log(isCidr('invalid-cidr')); // 0

Other packages similar to is-cidr

FAQs

Package last updated on 23 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc