MCPcopy Create free account
hub / github.com/nodejs/node / headerValueNormalize

Function headerValueNormalize

deps/undici/src/lib/web/fetch/headers.js:29–39  ·  view source on GitHub ↗

* @see https://fetch.spec.whatwg.org/#concept-header-value-normalize * @param {string} potentialValue * @returns {string}

(potentialValue)

Source from the content-addressed store, hash-verified

27 * @returns {string}
28 */
29function headerValueNormalize (potentialValue) {
30 // To normalize a byte sequence potentialValue, remove
31 // any leading and trailing HTTP whitespace bytes from
32 // potentialValue.
33 let i = 0; let j = potentialValue.length
34
35 while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(j - 1))) --j
36 while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(i))) ++i
37
38 return i === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i, j)
39}
40
41/**
42 * @param {Headers} headers

Callers 2

appendHeaderFunction · 0.70
setMethod · 0.70

Calls 1

isHTTPWhiteSpaceCharCodeFunction · 0.70

Tested by

no test coverage detected