Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Nagy <[email protected]>
  • Loading branch information
flakey5 and ronag authored Nov 9, 2024
1 parent 868af1c commit 9f467e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
9 changes: 1 addition & 8 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,7 @@ function encodeRawHeaders (headers) {
if (!Array.isArray(headers)) {
throw new TypeError('expected headers to be an array')
}

const rawHeaders = new Array(headers.length)

for (let i = 0; i < headers.length; i++) {
rawHeaders[i] = Buffer.from(headers[i])
}

return rawHeaders
return headers.map(x => Buffer.from(x))
}

/**
Expand Down
6 changes: 2 additions & 4 deletions lib/interceptor/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ module.exports = (opts = {}) => {

if (typeof handler.onConnect === 'function') {
handler.onConnect((err) => {
if (stream) {
stream.destroy(err)
}
stream?.destroy(err)
})

if (stream?.destroyed) {
Expand Down Expand Up @@ -182,7 +180,7 @@ module.exports = (opts = {}) => {
}

handleStream(result)
}).catch(handler.onError)
}).catch(err => handler.onError(err))
} else {
handleStream(result)
}
Expand Down
7 changes: 2 additions & 5 deletions lib/util/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ function makeCacheKey (opts) {
const cacheKey = {
origin: opts.origin.toString(),
method: opts.method,
path: opts.path
}

if (opts.headers) {
cacheKey.headers = opts.headers
path: opts.path,
headers: opts.headers
}

return cacheKey
Expand Down

0 comments on commit 9f467e7

Please sign in to comment.