From 61bbb3efe4dadf8c7dd8b330ddcf26dbb6a7aae5 Mon Sep 17 00:00:00 2001 From: Adarsh Singh Tomar Date: Mon, 17 Jun 2024 22:35:18 +0530 Subject: [PATCH] updated email validation regex --- package.json | 2 +- src/components/ui/EmailForm.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 822de0b..67321fc 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "remark-parse": "^11.0.0", "resend": "^3.3.0", "sharp": "^0.33.3", - "sonner": "^1.4.41", + "sonner": "^1.5.0", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7", "three": "^0.164.1", diff --git a/src/components/ui/EmailForm.tsx b/src/components/ui/EmailForm.tsx index 44c44e4..ba9acea 100644 --- a/src/components/ui/EmailForm.tsx +++ b/src/components/ui/EmailForm.tsx @@ -4,7 +4,7 @@ import { useState, ChangeEvent, FormEvent } from "react"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card"; -import { toast } from "sonner"; +import { toast} from "sonner"; interface EmailFormProps { url: string; @@ -37,7 +37,7 @@ export default function EmailForm({ url }: EmailFormProps) { }; const isValidEmail = (email: string) => { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); + return /^([A-Z0-9a-z._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z]{2,63})+)@(?![-])([a-zA-Z]{2,63})(?:\.[a-zA-Z]{2,63})+$/.test(email); // updated regex to verify approved domains }; const handleSendEmails = async () => {