fix: ending card url (#4364)

Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
Co-authored-by: Anshuman Pandey <54475686+pandeymangg@users.noreply.github.com>
This commit is contained in:
Piyush Gupta
2024-11-27 10:37:18 +05:30
committed by GitHub
parent 35eac02545
commit 78813d53b1
2 changed files with 11 additions and 3 deletions

View File

@@ -44,3 +44,11 @@ export type TAllowedFileExtension = z.infer<typeof ZAllowedFileExtension>;
export const ZId = z.string().cuid2();
export const ZUuid = z.string().uuid();
export const getZSafeUrl = (message: string): z.ZodEffects<z.ZodString, string, string> =>
z
.string()
.url({ message })
.refine((url) => url.startsWith("https://"), {
message: "URL must start with https://",
});

View File

@@ -2,7 +2,7 @@ import { type ZodIssue, z } from "zod";
import { ZSurveyFollowUp } from "@formbricks/database/types/survey-follow-up";
import { ZActionClass, ZActionClassNoCodeConfig } from "../action-classes";
import { ZAttributes } from "../attributes";
import { ZAllowedFileExtension, ZColor, ZId, ZPlacement } from "../common";
import { ZAllowedFileExtension, ZColor, ZId, ZPlacement, getZSafeUrl } from "../common";
import { ZInsight } from "../insights";
import { ZLanguage } from "../product";
import { ZSegment } from "../segment";
@@ -31,7 +31,7 @@ export const ZSurveyEndScreenCard = ZSurveyEndingBase.extend({
headline: ZI18nString.optional(),
subheader: ZI18nString.optional(),
buttonLabel: ZI18nString.optional(),
buttonLink: z.string().url("Invalid Button Url in Ending card").optional(),
buttonLink: getZSafeUrl("Invalid Button Url in Ending card").optional(),
imageUrl: z.string().optional(),
videoUrl: z.string().optional(),
});
@@ -40,7 +40,7 @@ export type TSurveyEndScreenCard = z.infer<typeof ZSurveyEndScreenCard>;
export const ZSurveyRedirectUrlCard = ZSurveyEndingBase.extend({
type: z.literal("redirectToUrl"),
url: z.string().url("Invalid Redirect Url in Ending card").optional(),
url: getZSafeUrl("Invalid Redirect Url").optional(),
label: z.string().optional(),
});