Skip to content

Commit

Permalink
fix: validate youtube links in media upload form (#188)
Browse files Browse the repository at this point in the history
this ensures that users enter youtube embed links, and don't paste
youtube.com/watch links in the media upload form.

closes #161
  • Loading branch information
stefanprobst authored Jun 19, 2024
2 parents 3f0a1d1 + c3bbfd6 commit b517a02
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/data/sshoc/validation-schemas/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
)

0 comments on commit b517a02

Please sign in to comment.