Fixes successRedirectUrl validation

pull/3676/head
zomars 2022-08-01 18:20:40 -06:00
parent 14443099e0
commit 6179b3fbe0
2 changed files with 8 additions and 13 deletions

View File

@ -854,7 +854,6 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
seatsPerTimeSlot,
recurringEvent,
locations,
successRedirectUrl,
...input
} = values;
@ -868,7 +867,6 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
id: eventType.id,
beforeEventBuffer: beforeBufferTime,
afterEventBuffer: afterBufferTime,
successRedirectUrl: successRedirectUrl || undefined,
seatsPerTimeSlot,
metadata: {
...(smartContractAddress ? { smartContractAddress } : {}),

View File

@ -118,15 +118,12 @@ export const userMetadata = z
* - XSS attempts through javascript:alert('hi')
* - mailto: links
*/
export function assertValidUrl(url: string) {
return url.startsWith("http://") && url.startsWith("https://");
}
export const successRedirectUrl = z
.string()
.url()
.refine(assertValidUrl, {
path: ["successRedirectUrl"],
message: "Invalid URL",
})
.nullish();
.union([
z.literal(""),
z
.string()
.url()
.regex(/^http(s)?:\/\/.*/),
])
.optional();