Skip to content

Commit 57a2581

Browse files
committed
fix regex for validating email
1 parent 01973ef commit 57a2581

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/routes/projectMemberInvites/create.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ const addMemberValidations = {
4040
const compareEmail = (email1, email2, options = { UNIQUE_GMAIL_VALIDATION: false }) => {
4141
if (options.UNIQUE_GMAIL_VALIDATION) {
4242
// email is gmail
43-
const emailSplit = /(^[\w.+-]+)(@gmail\..*.)$/g.exec(email1);
43+
const emailSplit = /(^[\w.+-]+)(@gmail\.com|@googlemail\.com)$/g.exec(_.toLower(email1));
4444
if (emailSplit) {
45-
const address = emailSplit[1];
46-
const emailDomain = emailSplit[2];
47-
const regexAddress = address.replace('.', '').split('').join('\.?'); // eslint-disable-line no-useless-escape
48-
const regex = new RegExp(_.toLower(`${regexAddress}${emailDomain}`));
45+
const address = emailSplit[1].replace('.', '');
46+
const emailDomain = emailSplit[2].replace('.', '\\.');
47+
const regexAddress = address.split('').join('\\.?');
48+
const regex = new RegExp(`${regexAddress}${emailDomain}`);
4949
return regex.test(_.toLower(email2));
5050
}
5151
}

0 commit comments

Comments
 (0)