(options: RequestInit, bodyIdentity: unknown)
| 483 | } |
| 484 | |
| 485 | function getOptionsForFetchCacheKey(options: RequestInit, bodyIdentity: unknown) { |
| 486 | const identity: Record<string, unknown> = {}; |
| 487 | |
| 488 | for (const [key, value] of Object.entries(options).sort(([keyA], [keyB]) => |
| 489 | keyA.localeCompare(keyB), |
| 490 | )) { |
| 491 | if (key === 'headers' || IGNORED_FETCH_CACHE_OPTION_KEYS.has(key)) { |
| 492 | continue; |
| 493 | } |
| 494 | |
| 495 | if (key === 'body') { |
| 496 | identity.body = bodyIdentity; |
| 497 | continue; |
| 498 | } |
| 499 | |
| 500 | if (value == null || ['boolean', 'number', 'string'].includes(typeof value)) { |
| 501 | identity[key] = value; |
| 502 | continue; |
| 503 | } |
| 504 | |
| 505 | return { cacheable: false, identity: undefined }; |
| 506 | } |
| 507 | |
| 508 | if (!Object.prototype.hasOwnProperty.call(options, 'body') && bodyIdentity !== undefined) { |
| 509 | identity.body = bodyIdentity; |
| 510 | } |
| 511 | |
| 512 | return { cacheable: true, identity }; |
| 513 | } |
| 514 | |
| 515 | function getFetchCacheKey( |
| 516 | url: RequestInfo, |
no test coverage detected
searching dependent graphs…