Skip to content

Commit 4b03fd3

Browse files
sahitya-chandraanikdhabal
authored andcommitted
fix: add strict URL validation with consistent error message (calcom#22843)
* added strict url validation with consistent Invalid URL error message * chore * Update schema.ts --------- Co-authored-by: Anik Dhabal Babu <[email protected]>
1 parent 0a1951d commit 4b03fd3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/features/form-builder/schema.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ export const fieldTypesSchemaMap: Partial<
418418
}
419419

420420
// 2. If it failed, try prepending https://
421-
const valueWithHttps = `https://${value}`;
422-
if (urlSchema.safeParse(valueWithHttps).success) {
423-
return;
421+
const domainLike = /^[a-z0-9.-]+\.[a-z]{2,}(\/.*)?$/i;
422+
if (domainLike.test(value)) {
423+
const valueWithHttps = `https://${value}`;
424+
if (urlSchema.safeParse(valueWithHttps).success) {
425+
return;
426+
}
424427
}
425428

426429
// 3. If all attempts fail, throw err

0 commit comments

Comments
 (0)