Skip to content

Commit

Permalink
Merge pull request #450 from Prefinem/clean-headers
Browse files Browse the repository at this point in the history
fixing when headers are undefined
  • Loading branch information
William authored Dec 1, 2021
2 parents 122aba7 + 89b3fef commit 75578a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
"staged": "lint-staged",
"test": "./node_modules/.bin/jest"
},
"version": "4.4.1"
"version": "4.4.2"
}
2 changes: 1 addition & 1 deletion src/server/proxyEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const handleRequestResponse = require('./handleRequestResponse');
const http = require('http');
const url = require('url');

const cleanHeaders = (headers) =>
const cleanHeaders = (headers = {}) =>
Object.keys(headers)
.filter((header) => typeof headers[header] !== 'undefined')
.reduce((result, header) => ({ ...result, [header]: headers[header] }), {});
Expand Down
13 changes: 13 additions & 0 deletions tests/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ test('iframe sends undefined cookie', async () => {

await expect(response.body).toEqual('SGVsbG8gV29ybGQh');
});

test('no headers sent', async () => {
const app = express();
const noHeaderEvent = { ...event };

noHeaderEvent.headers = undefined;

app.get('/', (req, res) => res.send('Hello World!'));

const response = await lambdaServer(app, true)(noHeaderEvent);

await expect(response.body).toEqual('SGVsbG8gV29ybGQh');
});

0 comments on commit 75578a7

Please sign in to comment.