Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 48975ad

Browse files
committed
refactor(@nguniversal/common): simplify TransferHttpCacheInterceptor intercept logic
(cherry picked from commit 03a7e55)
1 parent 71c2cef commit 48975ad

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

modules/common/clover/src/transfer-http-cache/transfer-http-cache.interceptor.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ export class TransferHttpCacheInterceptor implements HttpInterceptor {
7171
}
7272

7373
const storeKey = this.makeCacheKey(req.method, req.url, req.params, req.responseType);
74+
const response = this.transferState.get(storeKey, null);
7475

75-
if (this.transferState.hasKey(storeKey)) {
76+
if (response) {
7677
// Request found in cache. Respond using it.
77-
const response = this.transferState.get(storeKey, null);
78-
let body: ArrayBuffer | Blob | string | undefined = response?.body;
78+
let body: ArrayBuffer | Blob | string | undefined = response.body;
7979

80-
switch (response?.responseType) {
80+
switch (response.responseType) {
8181
case 'arraybuffer':
8282
{
8383
// If we're in Node...
@@ -102,10 +102,10 @@ export class TransferHttpCacheInterceptor implements HttpInterceptor {
102102
return of(
103103
new HttpResponse<any>({
104104
body,
105-
headers: new HttpHeaders(response?.headers),
106-
status: response?.status,
107-
statusText: response?.statusText,
108-
url: response?.url,
105+
headers: new HttpHeaders(response.headers),
106+
status: response.status,
107+
statusText: response.statusText,
108+
url: response.url,
109109
}),
110110
);
111111
}

0 commit comments

Comments
 (0)