|
|
|
|
@ -48,6 +48,9 @@ const RE_VALTOWN =
@@ -48,6 +48,9 @@ const RE_VALTOWN =
|
|
|
|
|
const RE_GENERIC_EMBED = |
|
|
|
|
/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i; |
|
|
|
|
|
|
|
|
|
const RE_GIPHY = |
|
|
|
|
/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/; |
|
|
|
|
|
|
|
|
|
const ALLOWED_DOMAINS = new Set([ |
|
|
|
|
"youtube.com", |
|
|
|
|
"youtu.be", |
|
|
|
|
@ -60,6 +63,7 @@ const ALLOWED_DOMAINS = new Set([
@@ -60,6 +63,7 @@ const ALLOWED_DOMAINS = new Set([
|
|
|
|
|
"*.simplepdf.eu", |
|
|
|
|
"stackblitz.com", |
|
|
|
|
"val.town", |
|
|
|
|
"giphy.com", |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
const createSrcDoc = (body: string) => { |
|
|
|
|
@ -309,6 +313,10 @@ export const extractSrc = (htmlString: string): string => {
@@ -309,6 +313,10 @@ export const extractSrc = (htmlString: string): string => {
|
|
|
|
|
return gistMatch[1]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (RE_GIPHY.test(htmlString)) { |
|
|
|
|
return `https://giphy.com/embed/${RE_GIPHY.exec(htmlString)![1]}`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const match = htmlString.match(RE_GENERIC_EMBED); |
|
|
|
|
if (match && match.length === 2) { |
|
|
|
|
return match[1]; |
|
|
|
|
|