How to use cidr-regex - 2 common examples

To help you get started, we’ve selected a few cidr-regex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github silverwind / is-cidr / index.js View on Github external
"use strict";
const cidrRegex = require("cidr-regex");
const re4 = cidrRegex.v4({exact: true});
const re6 = cidrRegex.v6({exact: true});

const isCidr = module.exports = str => {
  if (re4.test(str)) return 4;
  if (re6.test(str)) return 6;
  return 0;
};

isCidr.v4 = str => re4.test(str);
isCidr.v6 = str => re6.test(str);
github silverwind / is-cidr / index.js View on Github external
"use strict";
const cidrRegex = require("cidr-regex");
const re4 = cidrRegex.v4({exact: true});
const re6 = cidrRegex.v6({exact: true});

const isCidr = module.exports = str => {
  if (re4.test(str)) return 4;
  if (re6.test(str)) return 6;
  return 0;
};

isCidr.v4 = str => re4.test(str);
isCidr.v6 = str => re6.test(str);

cidr-regex

Regular expression for matching IP addresses in CIDR notation

BSD-2-Clause
Latest version published 16 days ago

Package Health Score

69 / 100
Full package analysis

Popular cidr-regex functions

Similar packages