Fix(isEmail): Added support for internationalized domain names
Added the allow_idn option which is passed down to isFQDN to check if the domain name contains non-ASCII characters. It defaults to true to maintain original behavior. If set to false, it rejects domain names in non-Latin alphabets like Arabic, Chinese, Cyrillic, etc.
Closes #2390
References
For more information on IDNs, please refer to the following:
- RFC 5890 - Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework
- Internationalized Domain Names - ICANN
Checklist
- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)
- [x] References provided in PR (where applicable)
Add tests too
Went ahead and added tests for isEmail and isURL with the new option, allow_idn, set to false.
Please update the README as well, see the checklist in the PR description
Can we get this merged? AWS SES doesn't seem to support special characters in the domain, resulting in the error: "Domain contains control or whitespace". I believe this PR can also be combined with https://github.com/validatorjs/validator.js/pull/2049 as it doesn't allow invisible characters as well (when combined with allow_utf8_local_part), but they should be added to the test cases.