Skip to content

Commit 33cb2de

Browse files
committed
Support x-www-form-urlencoded
1 parent 3a23d86 commit 33cb2de

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/server/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function (source) {
1515
var router = express.Router()
1616

1717
// Add middlewares
18-
router.use(bodyParser.json({limit: '10mb'}))
18+
router.use(bodyParser.json({limit: '10mb', extended: false}))
1919
router.use(bodyParser.urlencoded({extended: false}))
2020
router.use(methodOverride())
2121

test/server/plural.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,22 @@ describe('Server', function () {
469469
})
470470
})
471471

472+
it('should support x-www-form-urlencoded',
473+
function (done) {
474+
request(server)
475+
.post('/posts')
476+
.type('form')
477+
.send({body: 'foo'})
478+
.expect('Content-Type', /json/)
479+
.expect({id: 3, body: 'foo'})
480+
.expect(201)
481+
.end(function (err, res) {
482+
if (err) return done(err)
483+
assert.equal(db.posts.length, 3)
484+
done()
485+
})
486+
})
487+
472488
it('should respond with json, create a resource and generate string id',
473489
function (done) {
474490
request(server)

0 commit comments

Comments
 (0)