From 4166daf0a21ed11e2ca5465749f0524c4958c1a6 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 30 May 2025 10:00:17 -0700 Subject: [PATCH] Hide escape character for forward slash in JSON --- src-web/components/responseViewers/TextViewer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-web/components/responseViewers/TextViewer.tsx b/src-web/components/responseViewers/TextViewer.tsx index bf99c202..8b0a5606 100644 --- a/src-web/components/responseViewers/TextViewer.tsx +++ b/src-web/components/responseViewers/TextViewer.tsx @@ -119,6 +119,7 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas // Decode unicode sequences in the text to readable characters if (pretty) { body = decodeUnicodeLiterals(body); + body = body.replace(/\\\//g, '/'); // Hide unnecessary escaping of '/' by some older frameworks } return ( @@ -136,9 +137,8 @@ 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) => { + return text.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => { const charCode = parseInt(hex, 16); return String.fromCharCode(charCode); }); - return decoded; }