From 9729d4ff750b1e31b677a387ae4659d0ff70bcda Mon Sep 17 00:00:00 2001 From: larabr Date: Fri, 2 Feb 2024 14:55:31 +0100 Subject: [PATCH] Apply suggestions from code review [skip ci] Co-authored-by: Daniel Huigens --- src/util.js | 5 +++-- test/general/util.js | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util.js b/src/util.js index 0535c25a..188a86fa 100644 --- a/src/util.js +++ b/src/util.js @@ -459,8 +459,9 @@ const util = { /** * Test email format based on W3C HTML5 specification. - * This check is not exaustive, and includes a willful violation of RFC5322 - * (see https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)) + * This check is not exaustive, and does not match RFC 5322 exactly + * (see https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)), + * but is commonly used for email address validation. */ isEmailAddress: function(data) { if (!util.isString(data)) { diff --git a/test/general/util.js b/test/general/util.js index 5bf765c9..c17b88c8 100644 --- a/test/general/util.js +++ b/test/general/util.js @@ -108,7 +108,7 @@ export default () => describe('Util unit tests', function() { const data = 'test@example.com'; expect(util.isEmailAddress(data)).to.be.true; }); - it('should return true for valid email address (-- in domain part)', function() { + it('should return true for valid email address (internationalized domain name)', function() { const data = 'test@xn--wgv.xn--q9jyb4c'; expect(util.isEmailAddress(data)).to.be.true; }); @@ -116,8 +116,8 @@ export default () => describe('Util unit tests', function() { const data = 'test1@com.com09'; expect(util.isEmailAddress(data)).to.be.true; }); - it('should return false for invalid email address (no . in domain part)', function() { - const data = 'test@examplecom'; + it('should return true for valid email address (no . in domain part)', function() { + const data = 'test@localhost'; expect(util.isEmailAddress(data)).to.be.true; }); it('should return false for invalid email address (full userID)', function() {