* @see https://fetch.spec.whatwg.org/#header-value * @param {string} potentialValue
(potentialValue)
| 144 | * @param {string} potentialValue |
| 145 | */ |
| 146 | function 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 |
no test coverage detected