itty-lambda 1.0.3 → 1.0.5

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.
@@ -143,21 +143,26 @@ function objectsToHeaders(single, multi) {
143
143
  const input = {};
144
144
  // add each single value header, wrapped in array
145
145
  if (single) {
146
- for (const [key, value] of Object.entries(single)) {
146
+ for (let [key, value] of Object.entries(single)) {
147
+ key = key.toLowerCase();
148
+ value = value?.trim();
147
149
  if (value)
148
150
  input[key] = [value];
149
151
  }
150
152
  }
151
153
  // and each multi value header
152
154
  if (multi) {
153
- for (const [key, values] of Object.entries(multi)) {
155
+ // eslint-disable-next-line prefer-const
156
+ for (let [key, values] of Object.entries(multi)) {
157
+ key = key.toLowerCase();
154
158
  if (values) {
155
159
  // merge with any existing arrays of values
156
160
  if (undefined === input?.[key]) {
157
161
  input[key] = values;
158
162
  }
159
163
  else {
160
- for (const value of values) {
164
+ for (let value of values) {
165
+ value = value.trim();
161
166
  if (!input[key].includes(value))
162
167
  input[key].push(value);
163
168
  }
@@ -182,8 +187,8 @@ function headersToObjects(headers, splitIntoMultiValues = false) {
182
187
  const single = {};
183
188
  const multi = {};
184
189
  for (const [key, value] of headers.entries()) {
185
- if (splitIntoMultiValues && value.includes(',')) {
186
- multi[key] = value.split(/\s*,\s*/);
190
+ if (splitIntoMultiValues) {
191
+ multi[key] = value.split(',').map(v => v.trim());
187
192
  }
188
193
  else {
189
194
  single[key] = value;
@@ -143,21 +143,26 @@ function objectsToHeaders(single, multi) {
143
143
  const input = {};
144
144
  // add each single value header, wrapped in array
145
145
  if (single) {
146
- for (const [key, value] of Object.entries(single)) {
146
+ for (let [key, value] of Object.entries(single)) {
147
+ key = key.toLowerCase();
148
+ value = value?.trim();
147
149
  if (value)
148
150
  input[key] = [value];
149
151
  }
150
152
  }
151
153
  // and each multi value header
152
154
  if (multi) {
153
- for (const [key, values] of Object.entries(multi)) {
155
+ // eslint-disable-next-line prefer-const
156
+ for (let [key, values] of Object.entries(multi)) {
157
+ key = key.toLowerCase();
154
158
  if (values) {
155
159
  // merge with any existing arrays of values
156
160
  if (undefined === input?.[key]) {
157
161
  input[key] = values;
158
162
  }
159
163
  else {
160
- for (const value of values) {
164
+ for (let value of values) {
165
+ value = value.trim();
161
166
  if (!input[key].includes(value))
162
167
  input[key].push(value);
163
168
  }
@@ -182,8 +187,8 @@ function headersToObjects(headers, splitIntoMultiValues = false) {
182
187
  const single = {};
183
188
  const multi = {};
184
189
  for (const [key, value] of headers.entries()) {
185
- if (splitIntoMultiValues && value.includes(',')) {
186
- multi[key] = value.split(/\s*,\s*/);
190
+ if (splitIntoMultiValues) {
191
+ multi[key] = value.split(',').map(v => v.trim());
187
192
  }
188
193
  else {
189
194
  single[key] = value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-lambda",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "AWS Lambda support for itty-router",
5
5
  "author": "Evan Kaufman <evan@evanskaufman.com>",
6
6
  "license": "MIT",
@@ -44,28 +44,30 @@
44
44
  "docs-md": "typedoc --options typedoc.md.json",
45
45
  "link": "npm link && npm link itty-lambda",
46
46
  "lint": "eslint ./src/",
47
- "test": "nyc mocha ./test/unit/*.test.*js",
47
+ "test-prepare": "bash test/prep.sh",
48
+ "test-clean": "bash test/clean.sh",
49
+ "test": "npm run test-prepare && nyc mocha ./test/unit/*.test.*js",
48
50
  "tsc": "npm run tsc-cjs && npm run tsc-esm",
49
51
  "tsc-cjs": "tsc --module commonjs --outDir ./build/cjs/",
50
52
  "tsc-esm": "tsc --module nodenext --outDir ./build/esm/"
51
53
  },
52
54
  "devDependencies": {
53
- "@eslint/js": "^9.29.0",
54
- "@types/aws-lambda": "^8.10.150",
55
- "@types/node": "^24.2.0",
56
- "chai": "^5.2.1",
57
- "eslint": "^9.29.0",
58
- "mocha": "^11.7.1",
59
- "nyc": "^17.1.0",
60
- "sinon": "^21.0.0",
61
- "typedoc": "^0.28.8",
62
- "typedoc-github-theme": "^0.3.0",
63
- "typedoc-plugin-markdown": "^4.8.0",
64
- "typedoc-plugin-mdn-links": "^5.0.7",
65
- "typescript": "^5.8.3",
66
- "typescript-eslint": "^8.34.1"
55
+ "@eslint/js": "^10.0.1",
56
+ "@types/aws-lambda": "^8.10.161",
57
+ "@types/node": "^25.3.5",
58
+ "chai": "^6.2.2",
59
+ "eslint": "^10.0.3",
60
+ "mocha": "^11.7.5",
61
+ "nyc": "^18.0.0",
62
+ "sinon": "^21.0.2",
63
+ "typedoc": "^0.28.17",
64
+ "typedoc-github-theme": "^0.4.0",
65
+ "typedoc-plugin-markdown": "^4.10.0",
66
+ "typedoc-plugin-mdn-links": "^5.1.1",
67
+ "typescript": "^5.9.3",
68
+ "typescript-eslint": "^8.56.1"
67
69
  },
68
70
  "dependencies": {
69
- "itty-router": "^5.0.0"
71
+ "itty-router": "^5.0.23"
70
72
  }
71
73
  }