File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,13 @@ const mergeRequestConfig = function (config, req) {
105105 mergedConfig . debug = debug
106106 }
107107
108+ // Create a cache key method
109+ if ( requestConfig . key ) {
110+ mergedConfig . key = key ( requestConfig )
111+ }
112+
108113 // Generate request UUID
109- mergedConfig . uuid = config . key ( req )
114+ mergedConfig . uuid = mergedConfig . key ( req )
110115
111116 config . debug ( `Request config for ${ req . url } ` , mergedConfig )
112117
Original file line number Diff line number Diff line change 11/* globals describe it */
22
33import assert from 'assert'
4+ import isFunction from 'lodash/isFunction'
45
56import config from 'src/config'
67
@@ -54,7 +55,8 @@ describe('Per request config', () => {
5455 const mergedConfig = config . mergeRequestConfig ( globalConfig , fakeRequest )
5556
5657 assert . strictEqual ( mergedConfig . maxAge , requestConfig . maxAge )
57- assert . strictEqual ( mergedConfig . key , requestConfig . key )
58+ assert . ok ( isFunction ( mergedConfig . key ) )
59+ assert . strictEqual ( mergedConfig . key ( { url : 'url' } ) , 'myKey/url' )
5860 assert . deepStrictEqual ( mergedConfig . exclude , {
5961 ...globalConfig . exclude ,
6062 ...requestConfig . exclude
You can’t perform that action at this time.
0 commit comments