Skip to content

Commit

Permalink
fix(isMail):fixed consecutive hyphen check in domain part
Browse files Browse the repository at this point in the history
When doing check with isEmail('[email protected]'), now returns false and behaves as expected.
  • Loading branch information
kshavp committed Sep 19, 2023
1 parent b958bd7 commit 6b21186
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/isFQDN.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const default_fqdn_options = {
allow_numeric_tld: false,
allow_wildcard: false,
ignore_max_length: false,
disallow_consecutive_hyphens: true,
};

export default function isFQDN(str, options) {
Expand All @@ -19,6 +20,11 @@ export default function isFQDN(str, options) {
str = str.substring(0, str.length - 1);
}

/* Check for consecutive hyphens in the domain part */
if (options.disallow_consecutive_hyphens && /--/.test(str)) {
return false;
}

/* Remove the optional wildcard before checking validity */
if (options.allow_wildcard === true && str.indexOf('*.') === 0) {
str = str.substring(2);
Expand Down

0 comments on commit 6b21186

Please sign in to comment.