* Create a new `Request` based on the specified URL and `RequestInit` options, preserving only * metadata that are known to be safe. * * Currently, headers, referrer, referrer policy, redirect policy, an explicit * `credentials: 'omit'`, and the HTTP cache mode are preserved. On cross-or
(url: string, options: Request)
| 518 | * https://github.com/angular/angular/issues/41931#issuecomment-1227601347. |
| 519 | */ |
| 520 | private newRequestWithMetadata(url: string, options: Request): Request { |
| 521 | let headers = options.headers; |
| 522 | const parsedUrl = this.adapter.parseUrl(url, this.adapter.origin); |
| 523 | |
| 524 | const hasHeaders = headers.keys().next().done !== true; |
| 525 | |
| 526 | if (hasHeaders && parsedUrl.origin !== this.adapter.origin) { |
| 527 | headers = this.adapter.newHeaders(options.headers); |
| 528 | headers.delete('Authorization'); |
| 529 | headers.delete('Proxy-Authorization'); |
| 530 | headers.delete('Cookie'); |
| 531 | } |
| 532 | |
| 533 | const init: RequestInit = { |
| 534 | headers, |
| 535 | referrer: options.referrer, |
| 536 | referrerPolicy: options.referrerPolicy, |
| 537 | redirect: options.redirect, |
| 538 | }; |
| 539 | |
| 540 | if (options.credentials === 'omit') { |
| 541 | init.credentials = 'omit'; |
| 542 | } |
| 543 | |
| 544 | if (options.cache !== undefined) { |
| 545 | init.cache = options.cache; |
| 546 | } |
| 547 | |
| 548 | return this.adapter.newRequest(url, init); |
| 549 | } |
| 550 | |
| 551 | /** |
| 552 | * Construct a cache-busting URL for a given URL. |
nothing calls this directly
no test coverage detected
searching dependent graphs…