From c3bbfd693255c0fa3c05239856f9ad973a6fcebb Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Wed, 19 Jun 2024 14:50:26 +0200 Subject: [PATCH] fix: validate youtube links in media upload form --- src/data/sshoc/validation-schemas/media.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data/sshoc/validation-schemas/media.ts b/src/data/sshoc/validation-schemas/media.ts index 1a9c335d..70f0c7fc 100644 --- a/src/data/sshoc/validation-schemas/media.ts +++ b/src/data/sshoc/validation-schemas/media.ts @@ -60,3 +60,13 @@ export const mediaUploadSchema = params: { mediaInput: ['file', 'url'] }, }, ) + .refine( + (data) => { + if (data.sourceUrl != null && data.sourceUrl.includes('youtube.com/watch')) return false + return true + }, + { + message: 'Provide a youtube embed link, not a youtube watch link', + path: ['sourceUrl'], + }, + )