Skip to content

Commit b2b5404

Browse files
committed
Update UI element for turn functionality in web application. Made changes to web/turn.mjs to improve user experience and ensure proper functionality. Ready to be committed and pushed to main branch.
1 parent bc296b2 commit b2b5404

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

web/turn.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { readFile } from 'fs/promises';
33

44
const getPath = (subPath) => utilitas.__(import.meta.url, subPath);
55
const getHtml = async () => await readFile(getPath('turn.html'), 'utf-8');
6-
const renderHtml = async (data) => await getHtml().then((html) => html.replace("'{{data}}'", data));
6+
const safeStringify = (obj) => JSON.stringify(obj)
7+
.replace(/</g, '\\u003c')
8+
.replace(/>/g, '\\u003e')
9+
.replace(/&/g, '\\u0026')
10+
.replace(/\u2028/g, '\\u2028')
11+
.replace(/\u2029/g, '\\u2029');
12+
const renderHtml = async (data) => await getHtml().then((html) => html.replace("'{{data}}'", () => data));
713

814
const file = async (ctx) => {
915
try {
@@ -100,7 +106,7 @@ const process = async (ctx, next) => {
100106
});
101107
}
102108
});
103-
ctx.body = await renderHtml(JSON.stringify({
109+
ctx.body = await renderHtml(safeStringify({
104110
bot_id: result.bot_id, chat_id: result.chat_id,
105111
chat_type: result.chat_type, messages, prompt_count,
106112
}));

0 commit comments

Comments
 (0)