mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-01 03:33:40 -05:00
fix: CTA button URL fix (#2881)
This commit is contained in:
@@ -390,7 +390,7 @@ export type TSurveyNPSQuestion = z.infer<typeof ZSurveyNPSQuestion>;
|
||||
export const ZSurveyCTAQuestion = ZSurveyQuestionBase.extend({
|
||||
type: z.literal(TSurveyQuestionTypeEnum.CTA),
|
||||
html: ZI18nString.optional(),
|
||||
buttonUrl: z.string().url({ message: "Invalid button url" }).optional(),
|
||||
buttonUrl: z.string().optional(),
|
||||
buttonExternal: z.boolean(),
|
||||
dismissButtonLabel: ZI18nString.optional(),
|
||||
logic: z.array(ZSurveyCTALogic).optional(),
|
||||
@@ -763,6 +763,17 @@ export const ZSurvey = z
|
||||
ctx.addIssue(multiLangIssue);
|
||||
}
|
||||
}
|
||||
|
||||
if (question.buttonExternal) {
|
||||
const parsedButtonUrl = z.string().url().safeParse(question.buttonUrl);
|
||||
if (!parsedButtonUrl.success) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: `Question ${String(questionIndex + 1)} has an invalid button URL`,
|
||||
path: ["questions", questionIndex, "buttonUrl"],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (question.type === TSurveyQuestionTypeEnum.Matrix) {
|
||||
|
||||
Reference in New Issue
Block a user