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

Function headerStringTransform

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected