diff --git a/src/element/embeddable.ts b/src/element/embeddable.ts index ecd149f6..08988b28 100644 --- a/src/element/embeddable.ts +++ b/src/element/embeddable.ts @@ -40,6 +40,9 @@ const RE_TWITTER = /(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?twitter.com/; const RE_TWITTER_EMBED = /^$/i; @@ -53,6 +56,7 @@ const ALLOWED_DOMAINS = new Set([ "gist.github.com", "twitter.com", "stackblitz.com", + "val.town", ]); const createSrcDoc = (body: string) => { @@ -122,6 +126,14 @@ export const getEmbedLink = (link: string | null | undefined): EmbeddedLink => { return { link, aspectRatio, type }; } + const valLink = link.match(RE_VALTOWN); + if (valLink) { + link = + valLink[1] === "embed" ? valLink[0] : valLink[0].replace("/v", "/embed"); + embeddedLinkCache.set(originalLink, { link, aspectRatio, type }); + return { link, aspectRatio, type }; + } + if (RE_TWITTER.test(link)) { let ret: EmbeddedLink; // assume embed code