Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ip-cidr

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-cidr - npm Package Compare versions

Comparing version 3.0.9 to 3.0.10

1

index.d.ts

@@ -54,2 +54,3 @@ import { Address4, Address6 } from "ip-address";

export function isValidAddress(address: string): boolean;
export function isValidCIDR(address: string): boolean;
export function createAddress(address: string): Address;

@@ -56,0 +57,0 @@ }

@@ -204,2 +204,15 @@ "use strict";

IPCIDR.isValidCIDR = function (address) {
if(typeof address !== 'string' || !address.match('/')) {
return false;
}
try {
return !!this.createAddress(address);
}
catch(err) {
return false;
}
}
module.exports = IPCIDR;

2

package.json
{
"name": "ip-cidr",
"version": "3.0.9",
"version": "3.0.10",
"description": "Module for working with CIDR (v4, v6)",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -14,3 +14,3 @@ # Install

if(!IPCIDR.isValidAddress(address)) {
if(!IPCIDR.isValidCIDR(address)) {
return;

@@ -52,4 +52,7 @@ }

### .isValidAddress(address)
to check the address is valid or not
to check the address is valid or not (ip or cidr)
### .isValidCIDR(address)
to check the address is valid (only cidr)
### .createAddress(address)

@@ -56,0 +59,0 @@ to create an object address from the string

@@ -66,2 +66,30 @@ "use strict";

describe(".isValidAddress()", function () {
it('check a wrong address', function () {;
assert.isFalse(IPCIDR.isValidAddress('wrong'));
});
it('check an ip address', function () {;
assert.isTrue(IPCIDR.isValidAddress('1.1.1.1'));
});
it('check CIDR', function () {;
assert.isTrue(IPCIDR.isValidAddress('1.1.1.1/24'));
});
});
describe(".isValidCIDR()", function () {
it('check a wrong address', function () {;
assert.isFalse(IPCIDR.isValidCIDR('wrong'));
});
it('check an ip address', function () {;
assert.isFalse(IPCIDR.isValidCIDR('1.1.1.1'));
});
it('check CIDR', function () {;
assert.isTrue(IPCIDR.isValidCIDR('1.1.1.1/24'));
});
});
describe(".prototype.contains()", function () {

@@ -68,0 +96,0 @@ describe("check as string", function () {

Sorry, the diff of this file is too big to display

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