fix: CTA button URL fix (#2881)

This commit is contained in:
Anshuman Pandey
2024-07-12 20:52:33 +05:30
committed by GitHub
parent 816cbd2036
commit e83d27f07c
+12 -1
View File
@@ -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) {