Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(trace-viewer): Try to format any JSON response (#38547)

Chris97f40f003686
diff --git a/packages/trace-viewer/src/ui/networkResourceDetails.tsx b/packages/trace-viewer/src/ui/networkResourceDetails.tsx
index b419434aa9..6959e342af 100644
--- a/packages/trace-viewer/src/ui/networkResourceDetails.tsx
+++ b/packages/trace-viewer/src/ui/networkResourceDetails.tsx
@@ -24,6 +24,7 @@ import { generateCurlCommand, generateFetchCall } from '../third_party/devtools'
import { CopyToClipboardTextButton } from './copyToClipboard';
import { getAPIRequestCodeGen } from './codegen';
import type { Language } from '@isomorphic/locatorGenerators';
+import { isJsonMimeType } from '@isomorphic/mimeType';
import { msToString, useAsyncMemo, useSetting } from '@web/uiUtils';
import type { Entry } from '@trace/har';
import { useTraceModel } from './traceModelContext';
@@ -272,7 +273,7 @@ function formatBody(body: string | null, contentType: string): string {
if (bodyStr === '')
return '<Empty>';
- if (contentType.includes('application/json')) {
+ if (isJsonMimeType(contentType)) {
try {
return JSON.stringify(JSON.parse(bodyStr), null, 2);
} catch (err) {