1212 * @private
1313 */
1414
15- var bytes = require ( 'bytes' )
1615var createError = require ( 'http-errors' )
1716var debug = require ( 'debug' ) ( 'body-parser:urlencoded' )
1817var isFinished = require ( 'on-finished' ) . isFinished
1918var read = require ( '../read' )
2019var typeis = require ( 'type-is' )
2120var qs = require ( 'qs' )
22- var { getCharset, typeChecker } = require ( '../utils' )
21+ var { getCharset, normalizeOptions } = require ( '../utils' )
2322
2423/**
2524 * Module exports.
@@ -37,21 +36,12 @@ module.exports = urlencoded
3736
3837function urlencoded ( options ) {
3938 var opts = options || { }
39+ var { inflate, limit, verify, shouldParse } = normalizeOptions ( opts , 'application/x-www-form-urlencoded' )
4040
4141 var extended = Boolean ( opts . extended )
42- var inflate = opts . inflate !== false
43- var limit = typeof opts . limit !== 'number'
44- ? bytes . parse ( opts . limit || '100kb' )
45- : opts . limit
46- var type = opts . type || 'application/x-www-form-urlencoded'
47- var verify = opts . verify || false
4842 var charsetSentinel = opts . charsetSentinel
4943 var interpretNumericEntities = opts . interpretNumericEntities
5044
51- if ( verify !== false && typeof verify !== 'function' ) {
52- throw new TypeError ( 'option verify must be function' )
53- }
54-
5545 var defaultCharset = opts . defaultCharset || 'utf-8'
5646 if ( defaultCharset !== 'utf-8' && defaultCharset !== 'iso-8859-1' ) {
5747 throw new TypeError ( 'option defaultCharset must be either utf-8 or iso-8859-1' )
@@ -60,11 +50,6 @@ function urlencoded (options) {
6050 // create the appropriate query parser
6151 var queryparse = createQueryParser ( opts , extended )
6252
63- // create the appropriate type checking function
64- var shouldParse = typeof type !== 'function'
65- ? typeChecker ( type )
66- : type
67-
6853 function parse ( body , encoding ) {
6954 return body . length
7055 ? queryparse ( body , encoding )
0 commit comments