From cfdca36b4ee84397ed2cb1987982d502a3c8af0a Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 22 Jun 2023 15:07:06 +0800 Subject: [PATCH] fix: compatible with content-type extra semicolon (#5217) closes https://github.com/eggjs/egg/issues/5214 --- package.json | 2 +- test/app/middleware/body_parser.test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 11318b888f..bde4b15c66 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "graceful": "^1.1.0", "humanize-ms": "^1.2.1", "is-type-of": "^1.2.1", - "koa-bodyparser": "^4.3.0", + "koa-bodyparser": "^4.4.1", "koa-is-json": "^1.0.0", "koa-override": "^3.0.0", "ms": "^2.1.3", diff --git a/test/app/middleware/body_parser.test.js b/test/app/middleware/body_parser.test.js index 6c4a6999cf..c0a60dd433 100644 --- a/test/app/middleware/body_parser.test.js +++ b/test/app/middleware/body_parser.test.js @@ -50,6 +50,18 @@ describe('test/app/middleware/body_parser.test.js', () => { .expect(200); }); + // fix https://github.com/eggjs/egg/issues/5214 + it('should 200 when post json with `content-type: application/json;charset=utf-8;`', () => { + app.mockCsrf(); + return app.httpRequest() + .post('/test/body_parser/user') + .set('Cookie', cookies) + .set('Content-Type', 'application/json;charset=utf-8;') + .send({ test: 1 }) + .expect({ test: 1 }) + .expect(200); + }); + it('should 200 when post json body below the limit', () => { return app.httpRequest() .post('/test/body_parser/user')