Comparing version 1.4.0 to 1.5.0
@@ -37,2 +37,5 @@ /** | ||
opts.multipart = 'multipart' in opts ? opts.multipart : false; | ||
opts.urlencoded = 'urlencoded' in opts ? opts.urlencoded : true; | ||
opts.json = 'json' in opts ? opts.json : true; | ||
opts.text = 'text' in opts ? opts.text : true; | ||
opts.encoding = 'encoding' in opts ? opts.encoding : 'utf-8'; | ||
@@ -49,9 +52,9 @@ opts.jsonLimit = 'jsonLimit' in opts ? opts.jsonLimit : '1mb'; | ||
if (!opts.strict || ["GET", "HEAD", "DELETE"].indexOf(this.method.toUpperCase()) === -1) { | ||
if (this.is('json')) { | ||
if (opts.json && this.is('json')) { | ||
body = yield buddy.json(this, {encoding: opts.encoding, limit: opts.jsonLimit}); | ||
} | ||
else if (this.is('urlencoded')) { | ||
else if (opts.urlencoded && this.is('urlencoded')) { | ||
body = yield buddy.form(this, {encoding: opts.encoding, limit: opts.formLimit}); | ||
} | ||
else if (this.is('text')) { | ||
else if (opts.text && this.is('text')) { | ||
body = yield buddy.text(this, {encoding: opts.encoding, limit: opts.textLimit}); | ||
@@ -58,0 +61,0 @@ } |
{ | ||
"name": "koa-body", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A koa body parser middleware. Support multipart, urlencoded and json request bodies.", | ||
@@ -53,3 +53,3 @@ "main": "index.js", | ||
"should": "*", | ||
"supertest": "*" | ||
"supertest": "2.0.0" | ||
}, | ||
@@ -56,0 +56,0 @@ "contributors": [ |
@@ -69,3 +69,3 @@ koa-body [![Build Status](https://travis-ci.org/dlau/koa-body.png)](https://travis-ci.org/dlau/koa-body) [![Dependencies Status](https://david-dm.org/dlau/koa-body/status.svg)](https://david-dm.org/dlau/koa-body) | ||
app.listen(3131); | ||
console.log('curl -i http://localhost:3131/ -d "name=test"'); | ||
console.log('curl -i http://localhost:3131/users -d "name=test"'); | ||
``` | ||
@@ -84,2 +84,5 @@ | ||
- `multipart` **{Boolean}** Parse multipart bodies, default `false` | ||
- `urlencoded` **{Boolean}** Parse urlencoded bodies, default `true` | ||
- `text` **{Boolean}** Parse text bodies, default `true` | ||
- `json` **{Boolean}** Parse json bodies, default `true` | ||
- `formidable` **{Object}** Options to pass to the formidable multipart parser | ||
@@ -96,6 +99,6 @@ - `strict` **{Boolean}** If enabled, don't parse GET, HEAD, DELETE requests, default `true` | ||
- `bytesExpected` **{Integer}** The expected number of bytes in this form, default `null` | ||
- `maxFields` **{Integer}** Limits the number of fields that the querystring parser will decode, default `10` | ||
- `maxFieldsSize` **{Integer}** Limits the amount of memory a field (not file) can allocate _in bytes_, default `2mb` | ||
- `maxFields` **{Integer}** Limits the number of fields that the querystring parser will decode, default `1000` | ||
- `maxFieldsSize` **{Integer}** Limits the amount of memory all fields together (except files) can allocate in bytes. If this value is exceeded, an 'error' event is emitted, default `2mb (2 * 2 * 1024)` | ||
- `uploadDir` **{String}** Sets the directory for placing file uploads in, default `os.tmpDir()` | ||
- `keepExtensions` **{Boolean}** Files written to `uploadDir` will include the extensions of the original files, default `true` | ||
- `keepExtensions` **{Boolean}** Files written to `uploadDir` will include the extensions of the original files, default `false` | ||
- `hash` **{String}** If you want checksums calculated for incoming files, set this to either `'sha1'` or `'md5'`, default `false` | ||
@@ -110,3 +113,3 @@ - `multiples` **{Boolean}** Multiple file uploads or no, default `true` | ||
## Tests | ||
> As usual - `npm test` **or** if you have [mocha][mocha-url] globally - `mocha --harmony-generators`. | ||
> As usual - `npm test` **or** if you have [mocha](https://mochajs.org) globally - `mocha --harmony-generators`. | ||
@@ -113,0 +116,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11438
113
118