1
- import { type BaseInit , getCachedFunction , type TypedResponse } from '@dvcol/base-http-client' ;
1
+ import { type BaseInit , ExactMatchRegex , getCachedFunction , type TypedResponse } from '@dvcol/base-http-client' ;
2
2
import { CacheRetention } from '@dvcol/common-utils/common/cache' ;
3
3
4
4
import { getJsonWriter } from '@dvcol/common-utils/common/save' ;
@@ -89,6 +89,7 @@ export const getSessionUser = async (): Promise<string | undefined> => {
89
89
export const getCachedProgressEndpoint = ( cache : CacheStore < TraktApiResponse > ) => {
90
90
const origin = chromeRuntimeId ? undefined : `${ WebConfig . CorsProxy } /${ WebConfig . CorsPrefix . Trakt } ` ;
91
91
const url : string = ExternaLinks . trakt . onDeck ( origin ) ;
92
+ const template = { method : 'GET' , url } ;
92
93
const baseInit : BaseInit = { credentials : 'include' } ;
93
94
return getCachedFunction (
94
95
// @ts -expect-error -- CancellablePromise extends promise
@@ -110,11 +111,12 @@ export const getCachedProgressEndpoint = (cache: CacheStore<TraktApiResponse>) =
110
111
retention : CacheRetention . Hour * 2 ,
111
112
key : ( param , init ) => {
112
113
return JSON . stringify ( {
113
- template : { method : 'GET' , url } ,
114
+ template,
114
115
param,
115
116
init : { ...baseInit , ...init } ,
116
117
} ) ;
117
118
} ,
119
+ evictionKey : `{"template":${ JSON . stringify ( template ) . replace ( ExactMatchRegex , '\\$&' ) } ` ,
118
120
} ,
119
121
) ;
120
122
} ;
0 commit comments