MCPcopy Create free account
hub / github.com/Kong/insomnia / parse

Method parse

packages/insomnia-scripting-environment/src/objects/headers.ts:120–125  ·  view source on GitHub ↗

* Parses a header string into an array of key-value pair objects. * * The input string is expected to have headers separated by newline characters. * Each non-empty line is processed and converted into an object with `key` and `value` properties. * * @param headerString - The raw head

(headerString: string)

Source from the content-addressed store, hash-verified

118 * @returns An array of objects, where each object represents a header with `key` and `value` properties.
119 */
120 static parse(headerString: string): { key: string; value: string }[] {
121 return headerString
122 .split('\n')
123 .filter(kvPart => kvPart.trim() !== '')
124 .map(kvPart => Header.parseSingle(kvPart));
125 }
126
127 /**
128 * Parses a single HTTP header string into an object containing the key and value.

Callers

nothing calls this directly

Calls 3

mapMethod · 0.80
filterMethod · 0.80
parseSingleMethod · 0.45

Tested by

no test coverage detected