about summary refs log tree commit diff
path: root/src/lib/link-meta.ts
diff options
context:
space:
mode:
authorAryan Goharzad <arrygoo@gmail.com>2023-01-19 13:53:11 -0500
committerGitHub <noreply@github.com>2023-01-19 12:53:11 -0600
commitf10a8308d9f6bfb907c8a2458cbf78b4cfad88d2 (patch)
tree0cb50ba6736ea67773e76f9000d07095a654bb6d /src/lib/link-meta.ts
parent9230d52ff596056429a773298b2728619afe3432 (diff)
downloadvoidsky-f10a8308d9f6bfb907c8a2458cbf78b4cfad88d2.tar.zst
Fixes youtube embed issues (#50)
* fixes youtube embed

* move extractMetaHtml test to its own file

* tests cleanup

* Add fallback for youtube meta data

* lint

* Check for youtube in the url domain

* use hostname instead of full url to check for link domain

* checks only for domain
Diffstat (limited to 'src/lib/link-meta.ts')
-rw-r--r--src/lib/link-meta.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/link-meta.ts b/src/lib/link-meta.ts
index 9a0325c8f..7e0964c17 100644
--- a/src/lib/link-meta.ts
+++ b/src/lib/link-meta.ts
@@ -1,7 +1,8 @@
 import he from 'he'
-import {extractHtmlMeta, isBskyAppUrl} from './strings'
+import {isBskyAppUrl} from './strings'
 import {RootStoreModel} from '../state'
 import {extractBskyMeta} from './extractBskyMeta'
+import {extractHtmlMeta} from './extractHtmlMeta'
 
 export enum LikelyType {
   HTML,
@@ -59,7 +60,10 @@ export async function getLinkMeta(
     })
     const httpResBody = await httpRes.text()
     clearTimeout(to)
-    const httpResMeta = extractHtmlMeta(httpResBody)
+    const httpResMeta = extractHtmlMeta({
+      html: httpResBody,
+      hostname: urlp?.hostname,
+    })
     meta.title = httpResMeta.title ? he.decode(httpResMeta.title) : undefined
     meta.description = httpResMeta.description
       ? he.decode(httpResMeta.description)