diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js index 886a3ce..2bd4485 100644 --- a/lib/types/urlencoded.js +++ b/lib/types/urlencoded.js @@ -147,7 +147,7 @@ function extendedparser (options) { throw new TypeError('option parameterLimit must be a positive number') } - if(isNaN(depth) || depth < 0) { + if (isNaN(depth) || depth < 0) { throw new TypeError('option depth must be a zero or a positive number') } diff --git a/test/urlencoded.js b/test/urlencoded.js index fa5a815..970c1e1 100644 --- a/test/urlencoded.js +++ b/test/urlencoded.js @@ -220,22 +220,19 @@ describe('bodyParser.urlencoded()', function () { }) }) - describe('with depth option', function () { describe('when custom value set', function () { - it('should reject non possitive numbers', function () { assert.throws(createServer.bind(null, { extended: true, depth: -1 }), /TypeError: option depth must be a zero or a positive number/) assert.throws(createServer.bind(null, { extended: true, depth: NaN }), /TypeError: option depth must be a zero or a positive number/) - assert.throws(createServer.bind(null, { extended: true, depth: "beep" }), + assert.throws(createServer.bind(null, { extended: true, depth: 'beep' }), /TypeError: option depth must be a zero or a positive number/) }) - it('should parse up to the specified depth', function (done) { - this.server = createServer({ extended:true, depth: 10 }) + this.server = createServer({ extended: true, depth: 10 }) request(this.server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -244,7 +241,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should not parse beyond the specified depth', function (done) { - this.server = createServer({ extended:true, depth: 1 }) + this.server = createServer({ extended: true, depth: 1 }) request(this.server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -252,7 +249,6 @@ describe('bodyParser.urlencoded()', function () { .expect(400, '[querystring.parse.rangeError] The input exceeded the depth', done) }) }) - describe('when default value', function () { before(function () { @@ -265,7 +261,7 @@ describe('bodyParser.urlencoded()', function () { deepObject += '[p]' } deepObject += '=value' - + request(this.server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -281,21 +277,19 @@ describe('bodyParser.urlencoded()', function () { }) it('should not parse beyond the specified depth', function (done) { - var deepObject = 'a'; + var deepObject = 'a' for (var i = 0; i < 33; i++) { - deepObject += '[p]'; + deepObject += '[p]' } - deepObject += '=value'; + deepObject += '=value' request(this.server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') .send(deepObject) - .expect(400, '[querystring.parse.rangeError] The input exceeded the depth', done); - }); - + .expect(400, '[querystring.parse.rangeError] The input exceeded the depth', done) + }) }) - }) describe('with inflate option', function () {