mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-22 01:15:25 +03:00
fix: catch exceptions in HTML parser (#994)
This commit is contained in:
parent
70a4475eac
commit
79753fd508
1 changed files with 8 additions and 2 deletions
|
@ -106,8 +106,14 @@ export function convertMastodonHTML(html: string, customEmojis: Record<string, m
|
|||
}
|
||||
|
||||
export function htmlToText(html: string) {
|
||||
const tree = parse(html)
|
||||
return (tree.children as Node[]).map(n => treeToText(n)).join('').trim()
|
||||
try {
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue