Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(isMail):fixed consecutive hyphen check in domain part #2287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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