@middy/http-header-normalizer 7.6.6 → 7.6.8

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 +5 -1
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -85,15 +85,19 @@ const defaults = {
85
85
  normalizeHeaderKey,
86
86
  };
87
87
 
88
+ export const NORMALIZED_KEY_CACHE_MAX = 2000;
89
+
88
90
  const httpHeaderNormalizerMiddleware = (opts = {}) => {
89
91
  const options = { ...defaults, ...opts };
90
92
 
91
- // Cache for normalized header keys to avoid repeated split/map/join
92
93
  const normalizedKeyCache = new Map();
93
94
  const cachedNormalizeKey = (key) => {
94
95
  let normalized = normalizedKeyCache.get(key);
95
96
  if (normalized === undefined) {
96
97
  normalized = options.normalizeHeaderKey(key, options.canonical);
98
+ if (normalizedKeyCache.size >= NORMALIZED_KEY_CACHE_MAX) {
99
+ normalizedKeyCache.delete(normalizedKeyCache.keys().next().value);
100
+ }
97
101
  normalizedKeyCache.set(key, normalized);
98
102
  }
99
103
  return normalized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-header-normalizer",
3
- "version": "7.6.6",
3
+ "version": "7.6.8",
4
4
  "description": "HTTP header normalizer middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -65,10 +65,10 @@
65
65
  "url": "https://github.com/sponsors/willfarrell"
66
66
  },
67
67
  "dependencies": {
68
- "@middy/util": "7.6.6"
68
+ "@middy/util": "7.6.8"
69
69
  },
70
70
  "devDependencies": {
71
- "@middy/core": "7.6.6",
71
+ "@middy/core": "7.6.8",
72
72
  "@types/node": "^22.0.0"
73
73
  }
74
74
  }