mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 01:28:35 +02:00
Hide escape character for forward slash in JSON
This commit is contained in:
@@ -119,6 +119,7 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas
|
|||||||
// Decode unicode sequences in the text to readable characters
|
// Decode unicode sequences in the text to readable characters
|
||||||
if (pretty) {
|
if (pretty) {
|
||||||
body = decodeUnicodeLiterals(body);
|
body = decodeUnicodeLiterals(body);
|
||||||
|
body = body.replace(/\\\//g, '/'); // Hide unnecessary escaping of '/' by some older frameworks
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -136,9 +137,8 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas
|
|||||||
|
|
||||||
/** Convert \uXXXX to actual Unicode characters */
|
/** Convert \uXXXX to actual Unicode characters */
|
||||||
function decodeUnicodeLiterals(text: string): string {
|
function decodeUnicodeLiterals(text: string): string {
|
||||||
const decoded = text.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => {
|
return text.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => {
|
||||||
const charCode = parseInt(hex, 16);
|
const charCode = parseInt(hex, 16);
|
||||||
return String.fromCharCode(charCode);
|
return String.fromCharCode(charCode);
|
||||||
});
|
});
|
||||||
return decoded;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user