* Formats a request for consistent snapshot storage * Caches normalized headers to avoid repeated processing * * @param {SnapshotRequestOptions} opts - Request options * @param {import('./snapshot-utils').HeaderFilters} headerFilters - Cached header sets for performance * @param {SnapshotRecord
(opts, headerFilters, matchOptions = {})
| 122 | * @returns {SnapshotFormattedRequest} - Formatted request object |
| 123 | */ |
| 124 | function formatRequestKey (opts, headerFilters, matchOptions = {}) { |
| 125 | const url = new URL(opts.path, opts.origin) |
| 126 | |
| 127 | // Cache normalized headers if not already done |
| 128 | const normalized = opts._normalizedHeaders || normalizeHeaders(opts.headers) |
| 129 | if (!opts._normalizedHeaders) { |
| 130 | opts._normalizedHeaders = normalized |
| 131 | } |
| 132 | |
| 133 | return { |
| 134 | method: opts.method || 'GET', |
| 135 | url: normalizeUrlForMatching(url, matchOptions.matchQuery, matchOptions.normalizeQuery), |
| 136 | headers: filterHeadersForMatching(normalized, headerFilters, matchOptions), |
| 137 | body: normalizeBodyForMatching(opts.body, matchOptions.matchBody, matchOptions.normalizeBody) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Filters headers based on matching configuration |
no test coverage detected