Skip to content

The open alternative to Salesforce, designed for AI.

[Fix] URL inputs to not submit numeric hostnames and url without domain (#6482)

Nabhag Motivaras320742cdea36
diff --git a/packages/twenty-front/src/utils/validation-schemas/absoluteUrlSchema.ts b/packages/twenty-front/src/utils/validation-schemas/absoluteUrlSchema.ts
index a0deb4bfab2..0627b98e984 100644
--- a/packages/twenty-front/src/utils/validation-schemas/absoluteUrlSchema.ts
+++ b/packages/twenty-front/src/utils/validation-schemas/absoluteUrlSchema.ts
@@ -6,7 +6,18 @@ export const absoluteUrlSchema = z
.or(
z
.string()
- .transform((value) => `https://${value}`)
+ .transform((value) => {
+ try {
+ const url = `https://${value}`.trim();
+ return isNaN(Number(value.trim())) &&
+ new URL(url) &&
+ /\.[a-z]{2,}$/.test(url)
+ ? url
+ : '';
+ } catch {
+ return '';
+ }
+ })
.pipe(z.string().url()),
)
.or(z.literal(''));