@nxtedition/nxt-undici 6.0.7 → 6.0.9

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.
@@ -26,8 +26,7 @@ class CacheHandler extends DecoratorHandler {
26
26
  }
27
27
 
28
28
  onHeaders(statusCode, headers, resume) {
29
- if (statusCode !== 307) {
30
- // Only cache redirects...
29
+ if (statusCode !== 307 && statusCode !== 200) {
31
30
  return super.onHeaders(statusCode, headers, resume)
32
31
  }
33
32
 
@@ -67,19 +66,16 @@ class CacheHandler extends DecoratorHandler {
67
66
 
68
67
  const vary = {}
69
68
  if (headers.vary) {
70
- for (const key of [headers.vary]
71
- .flat()
72
- .flatMap((vary) => vary.split(',').map((key) => key.trim().toLowerCase()))) {
69
+ if (typeof headers.vary !== 'string') {
70
+ return super.onHeaders(statusCode, headers, resume)
71
+ }
72
+
73
+ for (const key of headers.vary.split(',').map((key) => key.trim().toLowerCase())) {
73
74
  const val = this.#key.headers[key]
74
- if (!val) {
75
- // Expect vary headers to be present...
76
- return super.onHeaders(statusCode, headers, resume)
75
+ if (val != null) {
76
+ vary[key] = this.#key.headers[key]
77
77
  }
78
- vary[key] = val
79
78
  }
80
-
81
- // Unexpected vary header type...
82
- return super.onHeaders(statusCode, headers, resume)
83
79
  }
84
80
 
85
81
  const ttl = cacheControlDirectives.immutable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "6.0.7",
3
+ "version": "6.0.9",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",