Skip to content

Commit b9d0d13

Browse files
committed
fixup
1 parent 59bcb75 commit b9d0d13

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/util/cache.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ function makeCacheKey (opts) {
1919
headers = {}
2020
} else if (typeof opts.headers[Symbol.iterator] === 'function') {
2121
headers = {}
22-
for (const [key, val] of opts.headers) {
22+
for (const x of opts.headers) {
23+
if (!Array.isArray(x)) {
24+
throw new Error('opts.headers is not a valid header map')
25+
}
26+
const [key, val] = x
2327
if (typeof key !== 'string' || typeof val !== 'string') {
2428
throw new Error('opts.headers is not a valid header map')
2529
}
@@ -31,21 +35,16 @@ function makeCacheKey (opts) {
3135
throw new Error('opts.headers is not an object')
3236
}
3337

34-
/**
35-
* @type {import('../../types/cache-interceptor.d.ts').default.CacheKey}
36-
*/
37-
const cacheKey = {
38+
return {
3839
origin: opts.origin.toString(),
3940
method: opts.method,
4041
path: opts.path,
4142
headers
4243
}
43-
44-
return cacheKey
4544
}
4645

4746
/**
48-
* @param {any} value
47+
* @param {any} key
4948
*/
5049
function assertCacheKey (key) {
5150
if (typeof key !== 'object') {

0 commit comments

Comments
 (0)