From 736f1f594c6a956d2eca32ffe054b71be186b2bc Mon Sep 17 00:00:00 2001 From: Sahitya Chandra Date: Fri, 8 Aug 2025 12:18:28 +0530 Subject: [PATCH] fix: add strict URL validation with consistent error message (#22843) * added strict url validation with consistent Invalid URL error message * chore * Update schema.ts --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> --- packages/features/form-builder/schema.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/features/form-builder/schema.ts b/packages/features/form-builder/schema.ts index 4ff75aefdd..420ac03718 100644 --- a/packages/features/form-builder/schema.ts +++ b/packages/features/form-builder/schema.ts @@ -418,9 +418,12 @@ export const fieldTypesSchemaMap: Partial< } // 2. If it failed, try prepending https:// - const valueWithHttps = `https://${value}`; - if (urlSchema.safeParse(valueWithHttps).success) { - return; + const domainLike = /^[a-z0-9.-]+\.[a-z]{2,}(\/.*)?$/i; + if (domainLike.test(value)) { + const valueWithHttps = `https://${value}`; + if (urlSchema.safeParse(valueWithHttps).success) { + return; + } } // 3. If all attempts fail, throw err