From ca186f3c0e2e4e5bae488dcd8e7dfc241d187bfc Mon Sep 17 00:00:00 2001 From: Philip Okugbe Date: Thu, 28 Nov 2024 18:53:49 +0000 Subject: [PATCH] fix: return direct embed urls if present (#516) --- .../editor/components/embed/providers.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/client/src/features/editor/components/embed/providers.ts b/apps/client/src/features/editor/components/embed/providers.ts index 6d92850..fe465f9 100644 --- a/apps/client/src/features/editor/components/embed/providers.ts +++ b/apps/client/src/features/editor/components/embed/providers.ts @@ -10,7 +10,10 @@ export const embedProviders: IEmbedProvider[] = [ id: 'loom', name: 'Loom', regex: /^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-zA-Z]+)\/?/, - getEmbedUrl: (match) => { + getEmbedUrl: (match, url) => { + if(url.includes("/embed/")){ + return url; + } return `https://loom.com/embed/${match[1]}`; } }, @@ -20,6 +23,9 @@ export const embedProviders: IEmbedProvider[] = [ regex: /^https:\/\/(www.)?airtable.com\/([a-zA-Z0-9]{2,})\/.*/, getEmbedUrl: (match, url: string) => { const path = url.split('airtable.com/'); + if(url.includes("/embed/")){ + return url; + } return `https://airtable.com/embed/${path[1]}`; } }, @@ -43,7 +49,10 @@ export const embedProviders: IEmbedProvider[] = [ id: 'miro', name: 'Miro', regex: /^https:\/\/(www\.)?miro\.com\/app\/board\/([\w-]+=)/, - getEmbedUrl: (match) => { + getEmbedUrl: (match, url) => { + if(url.includes("/live-embed/")){ + return url; + } return `https://miro.com/app/live-embed/${match[2]}?embedMode=view_only_without_ui&autoplay=true&embedSource=docmost`; } }, @@ -51,7 +60,10 @@ export const embedProviders: IEmbedProvider[] = [ id: 'youtube', name: 'YouTube', regex: /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/, - getEmbedUrl: (match) => { + getEmbedUrl: (match, url) => { + if (url.includes("/embed/")){ + return url; + } return `https://www.youtube-nocookie.com/embed/${match[5]}`; } },