diff --git a/index.js b/index.js index 5a6e022e..65898938 100644 --- a/index.js +++ b/index.js @@ -161,9 +161,6 @@ function loadParser (parserName) { case 'urlencoded': parser = require('./lib/types/urlencoded') break - case 'generic': - parser = require('./lib/generic-parser') - break } // store to prevent invoking require() diff --git a/lib/types/json.js b/lib/types/json.js index d72738eb..8bac395d 100644 --- a/lib/types/json.js +++ b/lib/types/json.js @@ -44,7 +44,7 @@ var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*(.)/ // eslint-disable-line no-cont * @public */ -function json(options) { +function json (options) { var opts = options || {} var reviver = opts.reviver @@ -55,11 +55,11 @@ function json(options) { return genericParser(assign({}, opts, { type: type, - charset: function validateCharset(charset) { + charset: function validateCharset (charset) { return charset.substr(0, 4) === 'utf-' }, - parse: function parse(buf) { + parse: function parse (buf) { if (buf.length === 0) { // special-case empty json body, as it's a common client-side mistake // TODO: maybe make this configurable or part of "strict" option @@ -97,7 +97,7 @@ function json(options) { * @private */ -function createStrictSyntaxError(parser, reviver, str, char) { +function createStrictSyntaxError (parser, reviver, str, char) { var index = str.indexOf(char) var partial = str.substring(0, index) + '#' @@ -119,7 +119,7 @@ function createStrictSyntaxError(parser, reviver, str, char) { * @private */ -function firstchar(str) { +function firstchar (str) { return FIRST_CHAR_REGEXP.exec(str)[1] } @@ -131,7 +131,7 @@ function firstchar(str) { * @return {SyntaxError} */ -function normalizeJsonSyntaxError(error, obj) { +function normalizeJsonSyntaxError (error, obj) { var keys = Object.getOwnPropertyNames(error) for (var i = 0; i < keys.length; i++) { diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js index 906ae412..715cb464 100644 --- a/lib/types/urlencoded.js +++ b/lib/types/urlencoded.js @@ -51,8 +51,8 @@ function urlencoded (options) { var queryparse = opts.parser || ( extended - ? extendedparser(opts) - : simpleparser(opts) + ? extendedparser(opts) + : simpleparser(opts) ) return genericParser(assign({}, opts, { diff --git a/package.json b/package.json index 15c32342..1ec27a68 100644 --- a/package.json +++ b/package.json @@ -50,4 +50,4 @@ "test-cov": "nyc --reporter=html --reporter=text npm test", "test-travis": "nyc --reporter=text npm test" } -} +} \ No newline at end of file diff --git a/test/json.js b/test/json.js index 6acd0bda..74634f21 100644 --- a/test/json.js +++ b/test/json.js @@ -75,10 +75,10 @@ describe('bodyParser.json()', function () { return { foo: 'bar' } } })) - .post('/') - .set('Content-Type', 'application/json') - .send('{"str":') - .expect(200, '{"foo":"bar"}', done) + .post('/') + .set('Content-Type', 'application/json') + .send('{"str":') + .expect(200, '{"foo":"bar"}', done) }) describe('when JSON is invalid', function () { diff --git a/test/urlencoded.js b/test/urlencoded.js index 166afdc4..a5036a01 100644 --- a/test/urlencoded.js +++ b/test/urlencoded.js @@ -23,10 +23,10 @@ describe('bodyParser.urlencoded()', function () { request(createServer({ parser: function (input) { return input.toUpperCase() } })) - .post('/') - .set('Content-Type', 'application/x-www-form-urlencoded') - .send('user=tobi') - .expect(200, '"USER=TOBI"', done) + .post('/') + .set('Content-Type', 'application/x-www-form-urlencoded') + .send('user=tobi') + .expect(200, '"USER=TOBI"', done) }) it('should 400 when invalid content-length', function (done) {