Decode html entities in link embeds

This commit is contained in:
Paul Frazee 2022-11-29 09:29:57 -06:00
parent 88c868dd80
commit 57f2d1d59f
4 changed files with 12 additions and 7 deletions

View file

@ -1,3 +1,4 @@
import he from 'he'
import {
extractHtmlMeta,
isBskyAppUrl,
@ -59,8 +60,10 @@ export async function getLinkMeta(url: string): Promise<LinkMeta> {
const httpRes = await fetch(url)
const httpResBody = await httpRes.text()
const httpResMeta = extractHtmlMeta(httpResBody)
meta.title = httpResMeta.title
meta.title = httpResMeta.title ? he.decode(httpResMeta.title) : undefined
meta.description = httpResMeta.description
? he.decode(httpResMeta.description)
: undefined
// TODO meta.image = httpResMeta.image
} catch (e) {
// failed