From e48f0a42894e17dcbd973ac2988b9909efef2ac7 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 2 Jan 2023 02:19:09 -0800 Subject: [PATCH] Update regex to support Youtube short URLs --- components/PartyDetails/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/PartyDetails/index.tsx b/components/PartyDetails/index.tsx index 84fe60c3..36eef570 100644 --- a/components/PartyDetails/index.tsx +++ b/components/PartyDetails/index.tsx @@ -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 = []