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 2.0.11 to 2.0.12

21

index.js

@@ -8,14 +8,21 @@ "use strict";

constructor(cidr) {
if(typeof cidr !== 'string') {
this._isValid = false;
return;
}
cidr.match(/:.\./) && (cidr = cidr.split(':').pop());
let ipAddressType = cidr.match(":")? ipAddress.Address6: ipAddress.Address4;
let address = new ipAddressType(cidr);
this._isValid = address.isValid();
if (this._isValid) {
this.cidr = cidr;
this.ipAddressType = ipAddressType;
this.address = address;
this.addressStart = address.startAddress();
this.addressEnd = address.endAddress();
if (!this._isValid) {
return;
}
this.cidr = cidr;
this.ipAddressType = ipAddressType;
this.address = address;
this.addressStart = address.startAddress();
this.addressEnd = address.endAddress();
}

@@ -22,0 +29,0 @@

{
"name": "ip-cidr",
"version": "2.0.11",
"version": "2.0.12",
"description": "Module for working with CIDR (v4, v6)",

@@ -26,3 +26,3 @@ "main": "./index.js",

"hooks": {
"pre-commit": "npm run test && npm run build"
"pre-commit": "npm run test && npm run build && git add ./dist/*"
}

@@ -29,0 +29,0 @@ },

@@ -9,2 +9,3 @@ "use strict";

let validCIDR = '5.5.5.8/29';
let validCIDRMapped = '5.5.5.8/29';
let validCIDRClear = '5.5.5.8';

@@ -34,2 +35,17 @@ let validCIDRStart = '5.5.5.8';

it('should be valid v6', function () {
let cidr = new IPCIDR('2001:db8::/120');
assert.isOk(cidr.isValid(), 'check the status');
assert.equal(cidr.addressStart.addressMinusSuffix, '2001:0db8:0000:0000:0000:0000:0000:0000', 'check the start');
assert.equal(cidr.addressEnd.addressMinusSuffix, '2001:0db8:0000:0000:0000:0000:0000:00ff', 'check the end');
});
it('should be valid mapped cidr', function () {
let cidr = new IPCIDR('::FFFF:' + validCIDRMapped);
assert.isOk(cidr.isValid(), 'check the status');
assert.equal(cidr.addressStart.addressMinusSuffix, validCIDRStart, 'check the start');
assert.equal(cidr.addressEnd.addressMinusSuffix, validCIDREnd, 'check the end');
});
it('should be invalid', function () {

@@ -45,3 +61,2 @@ let cidr = new IPCIDR(invalidCIDR);

assert.equal(cidr.formatIP(cidr.address), validCIDRClear);
const ipAddress = require('ip-address');
});

@@ -176,4 +191,4 @@

});
})
});
});

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