Skip to content

Commit

Permalink
Updated Lib IP regex's
Browse files Browse the repository at this point in the history
  • Loading branch information
h345983745 committed Jun 29, 2019
1 parent 63627c4 commit 92c0b07
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core/lib/IP.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,15 @@ export function ipv6Compare(a, b) {
const _LARGE_RANGE_ERROR = "The specified range contains more than 65,536 addresses. Running this query could crash your browser. If you want to run it, select the \"Allow large queries\" option. You are advised to turn off \"Auto Bake\" whilst editing large ranges.";

/**
* A regular expression that matches an IPv4 address
* A regular expression that matches an IPv4 address.
* @description Has the global flag set.
*/
export const IPV4_REGEX = /^\s*((?:\d{1,3}\.){3}\d{1,3})\s*$/;

export const IPV4_REGEX = new RegExp("(?:(?:\\d|[01]?\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d|\\d)(?:\\/\\d{1,2})?", "g");
/**
* A regular expression that matches an IPv6 address
* A regular expression that matches an IPv6 address.
* @description Has the global flag set.
*/
export const IPV6_REGEX = /^\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i;
export const IPV6_REGEX = new RegExp("((?=.*::)(?!.*::.+::)(::)?([\\dA-Fa-f]{1,4}:(:|\\b)|){5}|([\\dA-Fa-f]{1,4}:){6})((([\\dA-Fa-f]{1,4}((?!\\3)::|:\\b|(?![\\dA-Fa-f])))|(?!\\2\\3)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4})", "g");

/**
* Lookup table for Internet Protocols.
Expand Down

0 comments on commit 92c0b07

Please sign in to comment.