Skip to content

Scheduling infrastructure for absolutely everyone.

fix: add strict URL validation with consistent error message (#22843)

Sahitya Chandra736f1f594c6a
diff --git a/packages/features/form-builder/schema.ts b/packages/features/form-builder/schema.ts
index 4ff75aefdda..420ac03718f 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