Skip to content

Commit 8f04ca9

Browse files
authored
Merge pull request #1939 from BigOsvaap/fix-isFQDN-allow_numeric_tld-option
fix(isFQDN): allow_numeric_tld option didn't work
2 parents c57ff39 + c605fe6 commit 8f04ca9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/lib/isFQDN.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function isFQDN(str, options) {
3232
return false;
3333
}
3434

35-
if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
35+
if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
3636
return false;
3737
}
3838

test/validators.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,18 @@ describe('Validators', () => {
13091309
],
13101310
});
13111311
});
1312-
1312+
it('should validate FQDN with required allow_trailing_dot, allow_underscores and allow_numeric_tld options', () => {
1313+
test({
1314+
validator: 'isFQDN',
1315+
args: [
1316+
{ allow_trailing_dot: true, allow_underscores: true, allow_numeric_tld: true },
1317+
],
1318+
valid: [
1319+
'abc.efg.g1h.',
1320+
'as1s.sad3s.ssa2d.',
1321+
],
1322+
});
1323+
});
13131324
it('should validate alpha strings', () => {
13141325
test({
13151326
validator: 'isAlpha',

0 commit comments

Comments
 (0)