Fixes successRedirectUrl

commit b006240b0c
Merge: 6179b3fbe e7418f68a
Author: zomars <zomars@me.com>
Date:   Mon Aug 1 18:20:47 2022 -0600

    Merge branch 'main' into production

commit 6179b3fbe0
Author: zomars <zomars@me.com>
Date:   Mon Aug 1 18:20:40 2022 -0600

    Fixes successRedirectUrl validation

commit 14443099e0
Author: zomars <zomars@me.com>
Date:   Mon Aug 1 17:59:47 2022 -0600

    successRedirectUrl fixes
This commit is contained in:
zomars 2022-08-01 18:45:47 -06:00
parent e7418f68a4
commit 53de4ddaaf
2 changed files with 8 additions and 14 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,16 +118,12 @@ export const userMetadata = z
* - XSS attempts through javascript:alert('hi')
* - mailto: links
*/
export function assertValidUrl(url: string | null | undefined) {
if (!url) return false;
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();