Skip to content

Commit

Permalink
Removed Changes Outside Of Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
h345983745 committed May 12, 2019
1 parent bbf9320 commit dd9f69c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
13 changes: 0 additions & 13 deletions src/core/lib/Extract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,3 @@ export const URL_REGEX = new RegExp(protocol + hostname + "(?:" + port + ")?(?:"
* Domain name regular expression
*/
export const DOMAIN_REGEX = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/ig;


/**
* IPV4 regular expression
*/
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");


/**
* IPV6 regular expression
*/
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");

14 changes: 13 additions & 1 deletion src/core/operations/DefangIP.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import Operation from "../Operation";
import { IPV4_REGEX, IPV6_REGEX } from "../lib/Extract.mjs";


/**
* Defang IP operation
Expand Down Expand Up @@ -61,3 +61,15 @@ class DefangIP extends Operation {
}

export default DefangIP;


/**
* IPV4 regular expression
*/
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");


/**
* IPV6 regular expression
*/
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");
5 changes: 2 additions & 3 deletions src/core/operations/RegularExpression.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import XRegExp from "xregexp";
import Operation from "../Operation";
import Utils from "../Utils";
import OperationError from "../errors/OperationError";
import { IPV4_REGEX, IPV6_REGEX} from "../lib/Extract.mjs";

/**
* Regular expression operation
Expand Down Expand Up @@ -38,11 +37,11 @@ class RegularExpression extends Operation {
},
{
name: "IPv4 address",
value: IPV4_REGEX.source
value: "(?:(?:\\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})?"
},
{
name: "IPv6 address",
value: IPV6_REGEX.source
value: "((?=.*::)(?!.*::.+::)(::)?([\\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})"
},
{
name: "Email address",
Expand Down

0 comments on commit dd9f69c

Please sign in to comment.