Skip to content

Commit 2d83d0f

Browse files
perf: replace unescapeHtml DOMParser with html-entities decode (open-webui#23165)
1 parent 354a179 commit 2d83d0f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib/utils/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { marked } from 'marked';
2222
import markedExtension from '$lib/utils/marked/extension';
2323
import markedKatexExtension from '$lib/utils/marked/katex-extension';
2424
import hljs from 'highlight.js';
25+
import { decode } from 'html-entities';
2526

2627
//////////////////////////
2728
// Helper functions
@@ -167,9 +168,8 @@ function processChineseDelimiters(
167168
});
168169
}
169170

170-
export function unescapeHtml(html: string) {
171-
const doc = new DOMParser().parseFromString(html, 'text/html');
172-
return doc.documentElement.textContent;
171+
export function unescapeHtml(html: string): string {
172+
return decode(html);
173173
}
174174

175175
export const capitalizeFirstLetter = (string) => {

0 commit comments

Comments
 (0)