This commit is contained in:
Zef Hemel
2022-09-02 15:47:44 +02:00
parent 69ec24ee2d
commit 0272e0c4f0
+5 -1
View File
@@ -58,7 +58,11 @@ export async function titleUnfurlOptions(url: string): Promise<UnfurlOption[]> {
// Run on the server because plugs will likely rely on fetch for this // Run on the server because plugs will likely rely on fetch for this
export async function unfurlExec(id: string, url: string): Promise<string> { export async function unfurlExec(id: string, url: string): Promise<string> {
let replacement = await dispatchEvent(`unfurl:${id}`, url); let replacement = await dispatchEvent(`unfurl:${id}`, url);
return replacement[0]; if (replacement.length === 0) {
throw new Error("Unfurl failed");
} else {
return replacement[0];
}
} }
const titleRegex = /<title[^>]*>\s*([^<]+)\s*<\/title\s*>/i; const titleRegex = /<title[^>]*>\s*([^<]+)\s*<\/title\s*>/i;