Skip to content

Commit

Permalink
CC-1889
Browse files Browse the repository at this point in the history
  • Loading branch information
depperm committed Feb 16, 2025
1 parent 7906f9d commit 6ccbc89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/core/lib/Extract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ 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;


/**
* DMARC Domain name regular expression
*/
export const DMARC_DOMAIN_REGEX = /\b((?=[a-z0-9_-]{1,63}\.)(xn--)?[a-z0-9_]+(-[a-z0-9_]+)*\.)+[a-z]{2,63}\b/ig;
11 changes: 8 additions & 3 deletions src/core/operations/ExtractDomains.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import Operation from "../Operation.mjs";
import { search, DOMAIN_REGEX } from "../lib/Extract.mjs";
import { search, DOMAIN_REGEX, DMARC_DOMAIN_REGEX } from "../lib/Extract.mjs";
import { caseInsensitiveSort } from "../lib/Sort.mjs";

/**
Expand Down Expand Up @@ -39,6 +39,11 @@ class ExtractDomains extends Operation {
name: "Unique",
type: "boolean",
value: false
},
{
name: "Underscore (DMARC, DKIM, etc)",
type: "boolean",
value: false
}
];
}
Expand All @@ -49,11 +54,11 @@ class ExtractDomains extends Operation {
* @returns {string}
*/
run(input, args) {
const [displayTotal, sort, unique] = args;
const [displayTotal, sort, unique, dmarc] = args;

const results = search(
input,
DOMAIN_REGEX,
dmarc ? DMARC_DOMAIN_REGEX : DOMAIN_REGEX,
null,
sort ? caseInsensitiveSort : null,
unique
Expand Down

0 comments on commit 6ccbc89

Please sign in to comment.