MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / parseBodyForReport

Function parseBodyForReport

packages/server-e2e/src/report.ts:620–644  ·  view source on GitHub ↗
(body: NonNullable<RequestInit['body']>)

Source from the content-addressed store, hash-verified

618}
619
620function parseBodyForReport(body: NonNullable<RequestInit['body']>): unknown {
621 if (typeof body === 'string') {
622 try {
623 return JSON.parse(body) as unknown;
624 } catch {
625 return body;
626 }
627 }
628 if (body instanceof URLSearchParams) {
629 return body.toString();
630 }
631 if (body instanceof FormData) {
632 return '[FormData]';
633 }
634 if (body instanceof Blob) {
635 return `[Blob ${body.type || 'application/octet-stream'} ${body.size} bytes]`;
636 }
637 if (body instanceof ArrayBuffer) {
638 return `[ArrayBuffer ${body.byteLength} bytes]`;
639 }
640 if (ArrayBuffer.isView(body)) {
641 return `[${body.constructor.name} ${body.byteLength} bytes]`;
642 }
643 return '[ReadableStream]';
644}
645
646function responseForReport(text: string): { envelope?: unknown; raw?: string } {
647 try {

Callers 1

requestForFetchReportFunction · 0.85

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected