File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ The value will be associated with [`stale-while-revalidate`](https://www.mnot.ne
185185##### getKey
186186
187187Type: ` function ` <br />
188- Default: ` (req, res ) => normalizeUrl(req.url) `
188+ Default: ` ({ req } ) => normalizeUrl(req.url) `
189189
190190It determinates how the cache key should be computed, receiving ` req, res ` as input.
191191
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ function isEmpty (value) {
1919 )
2020}
2121
22- const _getKey = req => {
22+ const _getKey = ( { req } ) => {
2323 const url = new URL ( req . url , 'http://localhost' ) . toString ( )
2424 const { origin } = new URL ( url )
2525 const baseKey = normalizeUrl ( url , {
@@ -79,14 +79,15 @@ module.exports = ({
7979 ...compressOpts
8080 } )
8181
82- return async ( { req, res, ...opts } ) => {
82+ return async opts => {
83+ const { req, res } = opts ;
8384 const hasForce = Boolean (
8485 req . query ? req . query . force : parse ( req . url . split ( '?' ) [ 1 ] ) . force
8586 )
86- const key = getKey ( req , res )
87+ const key = getKey ( opts )
8788 const cachedResult = await decompress ( await cache . get ( key ) )
8889 const isHit = ! hasForce && cachedResult !== undefined
89- const result = isHit ? cachedResult : await get ( { req , res , ... opts } )
90+ const result = isHit ? cachedResult : await get ( opts )
9091
9192 if ( ! result ) return
9293
You can’t perform that action at this time.
0 commit comments