Skip to content

Commit 43890b9

Browse files
committed
Include function that strips anchor tags in sanitizeText function
1 parent 5a29db7 commit 43890b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

frontend/src/pages/Chat/utils/exportHelper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { IMessage } from "../../../hooks/useMessages";
22

33
function sanitizeText(str: string) {
4+
// Strips anchor tags
5+
str = str.replace(/<a\b[^>]*>(.*?)<\/a>/gi, "$1");
6+
47
return str
58
.replace(/&/g, "&amp;")
69
.replace(/</g, "&lt;")
@@ -18,7 +21,7 @@ export default function exportMessages(messages: IMessage[]) {
1821
({ role, content }) =>
1922
`<p><strong>${
2023
role.charAt(0).toUpperCase() + role.slice(1)
21-
}</strong>: ${sanitizeText(content)}</p>`,
24+
}</strong>: ${sanitizeText(content)}</p>`
2225
)
2326
.join("");
2427

0 commit comments

Comments
 (0)