MCPcopy Create free account
hub / github.com/WICG/webpackage / combineHeadersForUrl

Function combineHeadersForUrl

js/bundle/src/encoder.ts:301–320  ·  view source on GitHub ↗
(
  headers: Headers,
  overrideHeadersOption: OverrideHeadersOption,
  url: string
)

Source from the content-addressed store, hash-verified

299// Based on the type of the overrideHeadersOption combines the original headers
300// with the override headers.
301export 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}

Callers 2

addFileFunction · 0.90
addFilesRecursivelyFunction · 0.90

Calls 1

isHeadersFunction · 0.85

Tested by

no test coverage detected