( headers: Headers, overrideHeadersOption: OverrideHeadersOption, url: string )
| 299 | // Based on the type of the overrideHeadersOption combines the original headers |
| 300 | // with the override headers. |
| 301 | export function combineHeadersForUrl( |
| 302 | headers: Headers, |
| 303 | overrideHeadersOption: OverrideHeadersOption, |
| 304 | url: string |
| 305 | ) { |
| 306 | if (!overrideHeadersOption) return headers; |
| 307 | |
| 308 | const headersForUrl = |
| 309 | typeof overrideHeadersOption == 'function' |
| 310 | ? overrideHeadersOption(url) |
| 311 | : overrideHeadersOption; |
| 312 | |
| 313 | if (!isHeaders(headersForUrl)) { |
| 314 | throw new Error( |
| 315 | 'Malformatted override headers: They should be an object of strings.' |
| 316 | ); |
| 317 | } |
| 318 | |
| 319 | return { ...headers, ...headersForUrl }; |
| 320 | } |
no test coverage detected