Skip to content

Commit 2c96382

Browse files
committed
Added support for internationalized domain names
1 parent 66ddd9c commit 2c96382

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/lib/isEmail.js

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const default_email_options = {
1010
allow_underscores: false,
1111
require_display_name: false,
1212
allow_utf8_local_part: true,
13+
allow_idn: false,
1314
require_tld: true,
1415
blacklisted_chars: '',
1516
ignore_max_length: false,
@@ -144,11 +145,16 @@ export default function isEmail(str, options) {
144145
require_tld: options.require_tld,
145146
ignore_max_length: options.ignore_max_length,
146147
allow_underscores: options.allow_underscores,
148+
allow_idn: options.allow_idn,
147149
})) {
148150
if (!options.allow_ip_domain) {
149151
return false;
150152
}
151153

154+
if (!options.allow_idn) {
155+
return false;
156+
}
157+
152158
if (!isIP(domain)) {
153159
if (!domain.startsWith('[') || !domain.endsWith(']')) {
154160
return false;

src/lib/isFQDN.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const default_fqdn_options = {
77
allow_trailing_dot: false,
88
allow_numeric_tld: false,
99
allow_wildcard: false,
10+
allow_idn: false,
1011
ignore_max_length: false,
1112
};
1213

@@ -71,6 +72,11 @@ export default function isFQDN(str, options) {
7172
return false;
7273
}
7374

75+
// verify if domain is IDN
76+
if (!options.allow_idn && !/^[a-z0-9-]+$/i.test(part)) {
77+
return false;
78+
}
79+
7480
return true;
7581
});
7682
}

0 commit comments

Comments
 (0)