• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"use strict";
2const cidrRegex = require("cidr-regex");
3const re4 = cidrRegex.v4({exact: true});
4const re6 = cidrRegex.v6({exact: true});
5
6const isCidr = module.exports = str => {
7  if (re4.test(str)) return 4;
8  if (re6.test(str)) return 6;
9  return 0;
10};
11
12isCidr.v4 = str => re4.test(str);
13isCidr.v6 = str => re6.test(str);
14