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.
Files changed (2) hide show
  1. package/index.js +2 -3
  2. 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).some((key) => key.toLowerCase() === 'cache-control' && (options.headers['cache-control'] = options.headers[key]));
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'] || requestCacheControl['authorization']) return;
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 } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-http-cache",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Node.Js Utility for fetching multiple HTTP resources with browser-like cache management.",
5
5
  "keywords": [
6
6
  "http-cache",