How to use the ip-regex.v4 function in ip-regex

To help you get started, we’ve selected a few ip-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 chaijs / chai-http / dist / chai-http.js View on Github external
ip.v4 = function (str) {
	return ipRegex.v4({exact: true}).test(str);
};
github polkadot-js / common / packages / util / src / is / ip.ts View on Github external
export default function isIp (value: string, type?: IpTypes): boolean {
  if (type === 'v4') {
    return ipRegex.v4({ exact: true }).test(value);
  } else if (type === 'v6') {
    return ipRegex.v6({ exact: true }).test(value);
  }

  return ipRegex({ exact: true }).test(value);
}
github android-js / androidjs-builder / example / helloworld / node_modules / is-ip / index.js View on Github external
isIp.v4 = x => ipRegex.v4({exact: true}).test(x);
isIp.v6 = x => ipRegex.v6({exact: true}).test(x);
github sindresorhus / is-ip / index.js View on Github external
isIp.v4 = string => ipRegex.v4({exact: true}).test(string);
isIp.v6 = string => ipRegex.v6({exact: true}).test(string);
github kevva / url-regex / index.js View on Github external
module.exports = options => {
	options = {
		strict: true,
		...options
	};

	const protocol = `(?:(?:[a-z]+:)?//)${options.strict ? '' : '?'}`;
	const auth = '(?:\\S+(?::\\S*)?@)?';
	const ip = ipRegex.v4().source;
	const host = '(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)';
	const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*';
	const tld = `(?:\\.${options.strict ? '(?:[a-z\\u00a1-\\uffff]{2,})' : `(?:${tlds.sort((a, b) => b.length - a.length).join('|')})`})\\.?`;
	const port = '(?::\\d{2,5})?';
	const path = '(?:[/?#][^\\s"]*)?';
	const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld})${port}${path}`;

	return options.exact ? new RegExp(`(?:^${regex}$)`, 'i') : new RegExp(regex, 'ig');
};
github graalvm / graaljs / deps / npm / node_modules / cidr-regex / index.js View on Github external
"use strict";

const ipRegex = require("ip-regex");

const v4 = ipRegex.v4().source + "\\/(3[0-2]|[12]?[0-9])";
const v6 = ipRegex.v6().source + "\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])";

const cidr = module.exports = opts => opts && opts.exact ?
  new RegExp(`(?:^${v4}$)|(?:^${v6}$)`) :
  new RegExp(`(?:${v4})|(?:${v6})`, "g");

cidr.v4 = opts => opts && opts.exact ? new RegExp(`^${v4}$`) : new RegExp(v4, "g");
cidr.v6 = opts => opts && opts.exact ? new RegExp(`^${v6}$`) : new RegExp(v6, "g");

ip-regex

Regular expression for matching IP addresses (IPv4 & IPv6)

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis

Popular ip-regex functions