From af4c442105b7221536e292071e7bebd306ddb4ff Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 11 Aug 2022 20:23:33 -0700 Subject: [PATCH] Support Twitch video and channel embeds --- web/components/editor/embed-modal.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/components/editor/embed-modal.tsx b/web/components/editor/embed-modal.tsx index 55b72d19..6acfd8f0 100644 --- a/web/components/editor/embed-modal.tsx +++ b/web/components/editor/embed-modal.tsx @@ -1,4 +1,5 @@ import { Editor } from '@tiptap/react' +import { DOMAIN } from 'common/envs/constants' import { useState } from 'react' import { Button } from '../button' import { RichContent } from '../editor' @@ -39,6 +40,19 @@ const embedPatterns: EmbedPattern[] = [ rewrite: (id) => ``, }, + // Twitch is a bit annoying, since it requires the `&parent=DOMAIN` to match + { + // Twitch: https://www.twitch.tv/videos/1445087149 + regex: /^https?:\/\/www\.twitch\.tv\/videos\/(\d+)/, + rewrite: (id) => + ``, + }, + { + // Twitch: https://www.twitch.tv/sirsalty + regex: /^https?:\/\/www\.twitch\.tv\/([^\/]+)/, + rewrite: (channel) => + ``, + }, { regex: /^(https?:\/\/.*)/, rewrite: (url) => ``,