mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Better unicode un-escaping
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -14044,7 +14044,7 @@
|
|||||||
"postcss": "^8.4.45",
|
"postcss": "^8.4.45",
|
||||||
"postcss-nesting": "^13.0.0",
|
"postcss-nesting": "^13.0.0",
|
||||||
"tailwindcss": "^3.4.10",
|
"tailwindcss": "^3.4.10",
|
||||||
"vite": "6.2.6",
|
"vite": "6.2.7",
|
||||||
"vite-plugin-static-copy": "^2.2.0",
|
"vite-plugin-static-copy": "^2.2.0",
|
||||||
"vite-plugin-svgr": "^4.3.0",
|
"vite-plugin-svgr": "^4.3.0",
|
||||||
"vite-plugin-top-level-await": "^1.5.0",
|
"vite-plugin-top-level-await": "^1.5.0",
|
||||||
@@ -14584,9 +14584,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"src-web/node_modules/vite": {
|
"src-web/node_modules/vite": {
|
||||||
"version": "6.2.6",
|
"version": "6.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-6.2.7.tgz",
|
||||||
"integrity": "sha512-9xpjNl3kR4rVDZgPNdTL0/c6ao4km69a/2ihNQbcANz8RuCOK3hQBmLSJf3bRKVQjVMda+YvizNE8AwvogcPbw==",
|
"integrity": "sha512-qg3LkeuinTrZoJHHF94coSaTfIPyBYoywp+ys4qu20oSJFbKMYoIJo0FWJT9q6Vp49l6z9IsJRbHdcGtiKbGoQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -116,14 +116,16 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas
|
|||||||
body = formattedBody.data;
|
body = formattedBody.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode unicode sequences in the text to readable characters
|
// Decode unicode sequences in the text to readable characters
|
||||||
const decodedBodyText = unescape(body.replace(/\\u/g, '%u')) || body;
|
if (pretty) {
|
||||||
|
body = decodeUnicodeLiterals(body);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Editor
|
<Editor
|
||||||
readOnly
|
readOnly
|
||||||
className={className}
|
className={className}
|
||||||
defaultValue={decodedBodyText}
|
defaultValue={body}
|
||||||
language={language}
|
language={language}
|
||||||
actions={actions}
|
actions={actions}
|
||||||
extraExtensions={extraExtensions}
|
extraExtensions={extraExtensions}
|
||||||
@@ -132,3 +134,11 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert \uXXXX to actual Unicode characters */
|
||||||
|
function decodeUnicodeLiterals(text: string): string {
|
||||||
|
const decoded = text.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => {
|
||||||
|
const charCode = parseInt(hex, 16);
|
||||||
|
return String.fromCharCode(charCode);
|
||||||
|
});
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user