Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5852 from matrix-org/t3chguy/fix/15777
Browse files Browse the repository at this point in the history
Switch to a spec conforming email validation Regexp
  • Loading branch information
t3chguy authored Apr 19, 2021
2 parents 251cb41 + c726213 commit 50dd9da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

const EMAIL_ADDRESS_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
// Regexp based on Simpler Version from https://gist.github.com/gregseth/5582254 - matches RFC2822
const EMAIL_ADDRESS_REGEX = new RegExp(
"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" + // localpart
"@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$", "i");

export function looksValid(email: string): boolean {
return EMAIL_ADDRESS_REGEX.test(email);
Expand Down

0 comments on commit 50dd9da

Please sign in to comment.