fix: catch exceptions in HTML parser (#994)
parent
70a4475eac
commit
79753fd508
|
@ -106,8 +106,14 @@ export function convertMastodonHTML(html: string, customEmojis: Record<string, m
|
||||||
}
|
}
|
||||||
|
|
||||||
export function htmlToText(html: string) {
|
export function htmlToText(html: string) {
|
||||||
const tree = parse(html)
|
try {
|
||||||
return (tree.children as Node[]).map(n => treeToText(n)).join('').trim()
|
const tree = parse(html)
|
||||||
|
return (tree.children as Node[]).map(n => treeToText(n)).join('').trim()
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function treeToText(input: Node): string {
|
export function treeToText(input: Node): string {
|
||||||
|
|
Loading…
Reference in New Issue