MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / headerStringTransform

Function headerStringTransform

src/tools/emulation.ts:24–48  ·  view source on GitHub ↗
(
  value: string | undefined,
)

Source from the content-addressed store, hash-verified

22} from './ToolDefinition.js';
23
24function headerStringTransform(
25 value: string | undefined,
26): Record<string, string> | undefined {
27 if (value === undefined) {
28 return undefined;
29 }
30 if (value === '') {
31 return {};
32 }
33 try {
34 const parsed = JSON.parse(value);
35 if (
36 typeof parsed !== 'object' ||
37 parsed === null ||
38 Array.isArray(parsed)
39 ) {
40 throw new Error('Headers must be a JSON object');
41 }
42 return parsed as Record<string, string>;
43 } catch (error) {
44 throw new Error(
45 `Invalid JSON for headers: ${error instanceof Error ? error.message : String(error)}`,
46 );
47 }
48}
49
50const throttlingOptions: [string, ...string[]] = [
51 'Offline',

Callers

nothing calls this directly

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected