Decode html entities in link embeds
parent
88c868dd80
commit
57f2d1d59f
|
@ -22,6 +22,7 @@
|
||||||
"@zxing/text-encoding": "^0.9.0",
|
"@zxing/text-encoding": "^0.9.0",
|
||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
"email-validator": "^2.0.4",
|
"email-validator": "^2.0.4",
|
||||||
|
"he": "^1.2.0",
|
||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
"lodash.omit": "^4.5.0",
|
"lodash.omit": "^4.5.0",
|
||||||
"lru_map": "^0.4.1",
|
"lru_map": "^0.4.1",
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
"@babel/core": "^7.12.9",
|
"@babel/core": "^7.12.9",
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@react-native-community/eslint-config": "^2.0.0",
|
"@react-native-community/eslint-config": "^2.0.0",
|
||||||
|
"@types/he": "^1.1.2",
|
||||||
"@types/jest": "^26.0.23",
|
"@types/jest": "^26.0.23",
|
||||||
"@types/lodash.chunk": "^4.2.7",
|
"@types/lodash.chunk": "^4.2.7",
|
||||||
"@types/lodash.omit": "^4.5.7",
|
"@types/lodash.omit": "^4.5.7",
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import he from 'he'
|
||||||
import {
|
import {
|
||||||
extractHtmlMeta,
|
extractHtmlMeta,
|
||||||
isBskyAppUrl,
|
isBskyAppUrl,
|
||||||
|
@ -59,8 +60,10 @@ export async function getLinkMeta(url: string): Promise<LinkMeta> {
|
||||||
const httpRes = await fetch(url)
|
const httpRes = await fetch(url)
|
||||||
const httpResBody = await httpRes.text()
|
const httpResBody = await httpRes.text()
|
||||||
const httpResMeta = extractHtmlMeta(httpResBody)
|
const httpResMeta = extractHtmlMeta(httpResBody)
|
||||||
meta.title = httpResMeta.title
|
meta.title = httpResMeta.title ? he.decode(httpResMeta.title) : undefined
|
||||||
meta.description = httpResMeta.description
|
meta.description = httpResMeta.description
|
||||||
|
? he.decode(httpResMeta.description)
|
||||||
|
: undefined
|
||||||
// TODO meta.image = httpResMeta.image
|
// TODO meta.image = httpResMeta.image
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// failed
|
// failed
|
||||||
|
|
|
@ -9,12 +9,7 @@ import {
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {Entity} from '../../../third-party/api/src/client/types/app/bsky/feed/post'
|
import {Entity} from '../../../third-party/api/src/client/types/app/bsky/feed/post'
|
||||||
import {Link} from '../util/Link'
|
import {Link} from '../util/Link'
|
||||||
import {
|
import {LinkMeta, getLikelyType, LikelyType} from '../../../lib/link-meta'
|
||||||
LinkMeta,
|
|
||||||
getLinkMeta,
|
|
||||||
getLikelyType,
|
|
||||||
LikelyType,
|
|
||||||
} from '../../../lib/link-meta'
|
|
||||||
import {colors} from '../../lib/styles'
|
import {colors} from '../../lib/styles'
|
||||||
import {useStores} from '../../../state'
|
import {useStores} from '../../../state'
|
||||||
|
|
||||||
|
|
|
@ -2448,6 +2448,11 @@
|
||||||
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.41.tgz#f6ecf57d1b12d2befcce00e928a6a097c22980aa"
|
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.41.tgz#f6ecf57d1b12d2befcce00e928a6a097c22980aa"
|
||||||
integrity sha512-ewXv/ceBaJprikMcxCmWU1FKyMAQ2X7a9Gtmzw8fcg2kIePI1crERDM818W+XYrxqdBBOdlf2rm137bU+BltCA==
|
integrity sha512-ewXv/ceBaJprikMcxCmWU1FKyMAQ2X7a9Gtmzw8fcg2kIePI1crERDM818W+XYrxqdBBOdlf2rm137bU+BltCA==
|
||||||
|
|
||||||
|
"@types/he@^1.1.2":
|
||||||
|
version "1.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/he/-/he-1.1.2.tgz#0c8b275f36d2b8b651104638e4d45693349c3953"
|
||||||
|
integrity sha512-kSJPcLO1x+oolc0R89pUl2kozldQ/fVQ1C1p5mp8fPoLdF/ZcBvckaTC2M8xXh3GYendXvCpy5m/a2eSbfgNgw==
|
||||||
|
|
||||||
"@types/html-minifier-terser@^6.0.0":
|
"@types/html-minifier-terser@^6.0.0":
|
||||||
version "6.1.0"
|
version "6.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35"
|
resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35"
|
||||||
|
|
Loading…
Reference in New Issue