shared-http-cache 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -51,8 +51,7 @@ class SharedHttpCache {
|
|
|
51
51
|
const { url, options = {}, integrity, callback } = request;
|
|
52
52
|
if (!options.method) options.method = 'GET';
|
|
53
53
|
if (!options.headers) options.headers = {};
|
|
54
|
-
Object.keys(options.headers).
|
|
55
|
-
Object.keys(options.headers).some((key) => key.toLowerCase() === 'authorization' && (options.headers['authorization'] = options.headers[key]));
|
|
54
|
+
Object.keys(options.headers).forEach((key) => /\p{Lu}/u.test(key) && ((options.headers[key.toLowerCase()] = options.headers[key]), delete options.headers[key]));
|
|
56
55
|
// prettier-ignore
|
|
57
56
|
let response, buffer, headers, fromCache = true;
|
|
58
57
|
try {
|
|
@@ -98,7 +97,7 @@ class SharedHttpCache {
|
|
|
98
97
|
if (options.method !== 'GET') return;
|
|
99
98
|
if (headers['vary'] || headers['content-range'] || headers['set-cookie']) return;
|
|
100
99
|
if (responseCacheControl['no-store'] || responseCacheControl['private']) return;
|
|
101
|
-
if (requestCacheControl['no-store'] ||
|
|
100
|
+
if (requestCacheControl['no-store'] || options.headers['authorization']) return;
|
|
102
101
|
const store = async () => {
|
|
103
102
|
await this.store.rm.entry(this.cacheDir, url, { removeFully: true });
|
|
104
103
|
await this.store.put(this.cacheDir, url, buffer, integrity ? { metadata: { headers }, integrity } : { metadata: { headers } });
|