Skip to content

Commit

Permalink
fix: compatible with content-type extra semicolon (#5217)
Browse files Browse the repository at this point in the history
closes #5214
  • Loading branch information
fengmk2 committed Jun 22, 2023
1 parent a634334 commit cfdca36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions test/app/middleware/body_parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit cfdca36

Please sign in to comment.