Skip to content

Commit 5009704

Browse files
committed
update parsing when no headers are present
1 parent 9f70e2f commit 5009704

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
66

7+
## [3.6.3]  (2020-06-21)
8+
9+
### Fixed
10+
11+
- Fix changes to eagerly parse api payloads as JSON
12+
713
## [3.6.2]  (2020-06-21)
814

915
### Updated
@@ -241,6 +247,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/),
241247
- Update older libraries
242248
- Now publish from Git tags instead of master pushes
243249

250+
[3.6.3]: https://github.com/manwaring/lambda-wrapper/compare/v3.6.2...v3.6.3
251+
[3.6.2]: https://github.com/manwaring/lambda-wrapper/compare/v3.6.1...v3.6.2
244252
[3.6.1]: https://github.com/manwaring/lambda-wrapper/compare/v3.6.0...v3.6.1
245253
[3.6.0]: https://github.com/manwaring/lambda-wrapper/compare/v3.5.0...v3.6.0
246254
[3.5.0]: https://github.com/manwaring/lambda-wrapper/compare/v3.4.0...v3.5.0

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@manwaring/lambda-wrapper",
33
"description": "A lambda handler wrapper to abstract common functionality and provide useful defaults",
4-
"version": "3.6.2",
4+
"version": "3.6.3",
55
"scripts": {
66
"publish-please-dry-run": "publish-please --dry-run",
77
"publish-please": "publish-please",

src/api/parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Body parsing', () => {
3333

3434
it("Tries to parse body as JSON when content type isn't specified", () => {
3535
const json = { hello: 'world' };
36-
const headers = {};
36+
const headers = undefined;
3737
const body = new Body(JSON.stringify(json), headers).getParsedBody();
3838
expect(body).toEqual(json);
3939
});

src/api/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export class Body {
5454
}
5555

5656
private getContentType(): string {
57-
return this?.headers['Content-Type'] || this?.headers['CONTENT-TYPE'] || this?.headers['content-type'];
57+
return (
58+
this.headers && (this.headers['Content-Type'] || this.headers['CONTENT-TYPE'] || this.headers['content-type'])
59+
);
5860
}
5961

6062
private isFormUrlEncoded(contentType?: string): boolean {

0 commit comments

Comments
 (0)