Update regex to support Youtube short URLs

This commit is contained in:
Justin Edmund 2023-01-02 02:19:09 -08:00
parent b67845f4e7
commit e48f0a4289

View file

@ -164,7 +164,8 @@ const PartyDetails = (props: Props) => {
function extractYoutubeVideoIds(text: string) {
// Create a regular expression to match Youtube URLs in the text
const youtubeUrlRegex = /https:\/\/www\.youtube\.com\/watch\?v=([\w-]+)/g
const youtubeUrlRegex =
/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/watch\?v=)([^&]+)/
// Initialize an array to store the video IDs
const videoIds = []