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>
This commit is contained in:
Sahitya Chandra
2025-08-08 06:48:28 +00:00
committed by GitHub
co-authored by Anik Dhabal Babu
parent 09b1643478
commit 736f1f594c
+6 -3
View File
@@ -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