From a67f0909ef99e76365d67fa62a0e38ec1255ed6b Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Mon, 10 Mar 2025 17:20:59 +0000 Subject: [PATCH] Update regex --- apps/web/src/utils/is-valid-name.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/web/src/utils/is-valid-name.ts b/apps/web/src/utils/is-valid-name.ts index c0873ddd9..a71f8203f 100644 --- a/apps/web/src/utils/is-valid-name.ts +++ b/apps/web/src/utils/is-valid-name.ts @@ -5,9 +5,14 @@ */ export function isValidName(value: string) { // Check for URL patterns - const urlPattern = - /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/i; - if (urlPattern.test(value)) { + // First check for common prefixes to avoid false positives with names like "Dr. Smith" + if (/(https?:\/\/|www\.|http:|https:)/.test(value)) { + return false; + } + + // Common TLDs that would indicate a URL + const commonTLDs = /\.(com|org|net|edu|gov|io|co|me|app|dev|info)(\s|$|\/)/i; + if (commonTLDs.test(value)) { return false; }