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

Function isValidHeaderValue

deps/undici/src/lib/web/fetch/util.js:146–158  ·  view source on GitHub ↗

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

(potentialValue)

Source from the content-addressed store, hash-verified

144 * @param {string} potentialValue
145 */
146function isValidHeaderValue (potentialValue) {
147 // - Has no leading or trailing HTTP tab or space bytes.
148 // - Contains no 0x00 (NUL) or HTTP newline bytes.
149 return (
150 potentialValue[0] === '\t' ||
151 potentialValue[0] === ' ' ||
152 potentialValue[potentialValue.length - 1] === '\t' ||
153 potentialValue[potentialValue.length - 1] === ' ' ||
154 potentialValue.includes('\n') ||
155 potentialValue.includes('\r') ||
156 potentialValue.includes('\0')
157 ) === false
158}
159
160/**
161 * Parse a referrer policy from a Referrer-Policy header

Callers 3

responseLocationURLFunction · 0.70
appendHeaderFunction · 0.70
setMethod · 0.70

Calls 1

includesMethod · 0.80

Tested by

no test coverage detected