Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Switch email pattern to practical implementation of RFC 5322
Browse files Browse the repository at this point in the history
  • Loading branch information
jblandry committed Nov 5, 2020
1 parent 23a7af9 commit c644c79
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kafe/string-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
validate.isEmail = function(str) {
str = str.replace(/^\s*|\s*$/g, '');
str = str.replace(/^\t*|\t*$/g, '');
return (/^\w+([\.\+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str));

// Practical implementation of RFC 5322
// https://www.regular-expressions.info/email.html
return (/^[a-z0-9!#$%&'*+/=?^_‘{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_‘{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(str));
};


Expand Down

0 comments on commit c644c79

Please sign in to comment.