How to use ip-regex - 10 common examples

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 passbolt / passbolt_browser_extension / src / all / data / js / quickaccess / popup / components / HomePage / canSuggestUrl.js View on Github external
// Check the port, if the suggest url has defined it.
  if (suggestedUrlObject.port) {
    if (urlObject.port !== suggestedUrlObject.port) {
      return false;
    }
  }

  // Perfect match.
  if (urlObject.hostname === suggestedUrlObject.hostname) {
    return true;
  }

  // If IPs, make a strict comparison.
  const urlIsIpAddress = ipRegex({exact: true}).test(urlObject.hostname);
  const suggestUrlIsIpAddress = ipRegex({exact: true}).test(suggestedUrlObject.hostname);
  if (urlIsIpAddress || suggestUrlIsIpAddress) {
    return urlObject.hostname === suggestedUrlObject.hostname;
  }

  // Otherwise check if the suggested url hostname is a parent host of the url hostname.
  return isParentHostname(suggestedUrlObject.hostname, urlObject.hostname);
}
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 chaijs / chai-http / dist / chai-http.js View on Github external
ip.v6 = function (str) {
	return ipRegex.v6({exact: true}).test(str);
};
github sindresorhus / is-ip / index.js View on Github external
isIp.v6 = string => ipRegex.v6({exact: true}).test(string);
isIp.version = string => isIp(string) ? (isIp.v4(string) ? 4 : 6) : undefined;
github taobataoma / meanTorrent / modules / announce / server / controllers / announces.server.controller.js View on Github external
function hasV6IP(peers) {
    for (let p of peers) {
      if (ipRegex.v6({exact: true}).test(p.ip)) {
        return true;
      }
    }
    return false;
  }
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);
}

ip-regex

Regular expression for matching IP addresses (IPv4 & IPv6)

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular ip-regex functions