@serwist/cacheable-response
Advanced tools
Comparing version 9.0.0-preview.10 to 9.0.0-preview.11
@@ -10,5 +10,3 @@ export interface CacheableResponseOptions { | ||
*/ | ||
headers?: { | ||
[headerName: string]: string; | ||
}; | ||
headers?: HeadersInit; | ||
} | ||
@@ -15,0 +13,0 @@ /** |
@@ -33,3 +33,5 @@ import { SerwistError, assert, logger, getFriendlyURL } from '@serwist/core/internal'; | ||
this._statuses = config.statuses; | ||
this._headers = config.headers; | ||
if (config.headers) { | ||
this._headers = new Headers(config.headers); | ||
} | ||
} | ||
@@ -50,5 +52,8 @@ isResponseCacheable(response) { | ||
if (this._headers && cacheable) { | ||
cacheable = Object.keys(this._headers).some((headerName)=>{ | ||
return response.headers.get(headerName) === this._headers[headerName]; | ||
}); | ||
for (const [headerName, headerValue] of this._headers.entries()){ | ||
if (response.headers.get(headerName) !== headerValue) { | ||
cacheable = false; | ||
break; | ||
} | ||
} | ||
} | ||
@@ -55,0 +60,0 @@ if (process.env.NODE_ENV !== "production") { |
{ | ||
"name": "@serwist/cacheable-response", | ||
"version": "9.0.0-preview.10", | ||
"version": "9.0.0-preview.11", | ||
"type": "module", | ||
"description": "This library takes a Response object and determines whether it's cacheable based on a specific configuration.", | ||
"description": "A module that takes a Response object and determines whether it's cacheable based on a specific configuration.", | ||
"files": [ | ||
@@ -32,3 +32,3 @@ "src", | ||
"dependencies": { | ||
"@serwist/core": "9.0.0-preview.10" | ||
"@serwist/core": "9.0.0-preview.11" | ||
}, | ||
@@ -38,3 +38,3 @@ "devDependencies": { | ||
"typescript": "5.4.0-dev.20240206", | ||
"@serwist/constants": "9.0.0-preview.10" | ||
"@serwist/constants": "9.0.0-preview.11" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependencies": { |
@@ -20,3 +20,3 @@ /* | ||
*/ | ||
headers?: { [headerName: string]: string }; | ||
headers?: HeadersInit; | ||
} | ||
@@ -32,3 +32,3 @@ | ||
private readonly _statuses?: CacheableResponseOptions["statuses"]; | ||
private readonly _headers?: CacheableResponseOptions["headers"]; | ||
private readonly _headers?: Headers; | ||
@@ -74,3 +74,5 @@ /** | ||
this._statuses = config.statuses; | ||
this._headers = config.headers; | ||
if (config.headers) { | ||
this._headers = new Headers(config.headers); | ||
} | ||
} | ||
@@ -104,5 +106,8 @@ | ||
if (this._headers && cacheable) { | ||
cacheable = Object.keys(this._headers).some((headerName) => { | ||
return response.headers.get(headerName) === this._headers![headerName]; | ||
}); | ||
for (const [headerName, headerValue] of this._headers.entries()) { | ||
if (response.headers.get(headerName) !== headerValue) { | ||
cacheable = false; | ||
break; | ||
} | ||
} | ||
} | ||
@@ -109,0 +114,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16759
341
+ Added@serwist/core@9.0.0-preview.11(transitive)
- Removed@serwist/core@9.0.0-preview.10(transitive)