Skip to content

Commit

Permalink
Add koa as peerDeps and fix the encoding option propagation (#160)
Browse files Browse the repository at this point in the history
## Description

Fix #155 and #157

## Checklist

- [x] I have ensured my pull request is not behind the main or master
branch of the original repository.
- [x] I have rebased all commits where necessary so that reviewing this
pull request can be done without having to merge it first.
- [x] I have written a commit message that passes commitlint linting.
- [x] I have ensured that my code changes pass linting tests.
- [x] I have ensured that my code changes pass unit tests.
- [x] I have described my pull request and the reasons for code changes
along with context if necessary.
  • Loading branch information
3imed-jaberi committed Apr 8, 2024
1 parent 8018af8 commit f27be45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@koa/bodyparser",
"version": "5.1.0",
"version": "5.1.1",
"description": "Koa body parsing middleware",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -69,6 +69,9 @@
"lodash.merge": "^4.6.2",
"type-is": "^1.6.18"
},
"peerDependencies": {
"koa": "^2.14.1"
},
"engines": {
"node": ">= 16"
},
Expand Down
2 changes: 2 additions & 0 deletions src/body-parser.ts
Expand Up @@ -66,6 +66,8 @@ export function bodyParserWrapper(opts: BodyParserOptions = {}) {
strict: bodyType === 'json' ? restOpts.jsonStrict : undefined,
[`${bodyType}Types`]: mimeTypes[bodyType],
limit: restOpts[`${shouldParseBodyAs('xml') ? 'xml' : bodyType}Limit`],
// eslint-disable-next-line unicorn/text-encoding-identifier-case
encoding: restOpts.encoding || 'utf-8',
};

return parser[bodyType](ctx, parserOptions) as Promise<
Expand Down
2 changes: 1 addition & 1 deletion test/middleware.test.ts
Expand Up @@ -56,7 +56,7 @@ describe("test/body-parser.test.ts", () => {
.expect({ foo: "bar" });
});

it.only("should parse json body with `content-type: application/json;charset=utf-8;` headers ok", async () => {
it("should parse json body with `content-type: application/json;charset=utf-8;` headers ok", async () => {
app.use(bodyParser());

app.use(async (ctx) => {
Expand Down

1 comment on commit f27be45

@titanism
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my only ask next time is to not do a version bump

Please sign in to comment.