( req: Pick<http.IncomingMessage, "headers">, headerName: string )
| 178 | }; |
| 179 | |
| 180 | function getFirstHeaderValue( |
| 181 | req: Pick<http.IncomingMessage, "headers">, |
| 182 | headerName: string |
| 183 | ): string | null { |
| 184 | const rawValue = req.headers[headerName.toLowerCase()]; |
| 185 | const value = Array.isArray(rawValue) ? rawValue[0] : rawValue; |
| 186 | |
| 187 | if (typeof value !== "string") { |
| 188 | return null; |
| 189 | } |
| 190 | |
| 191 | const firstValue = value.split(",")[0]?.trim(); |
| 192 | return firstValue?.length ? firstValue : null; |
| 193 | } |
| 194 | |
| 195 | function normalizeProtocol(rawProtocol: string): "http" | "https" | null { |
| 196 | const normalized = rawProtocol.trim().toLowerCase().replace(/:$/, ""); |
no outgoing calls
no test coverage detected