* Create a middleware to parse urlencoded bodies. * * @param {Object} [options] * @returns {Function} * @public
(options)
| 32 | * @public |
| 33 | */ |
| 34 | function urlencoded (options) { |
| 35 | const normalizedOptions = normalizeOptions(options, 'application/x-www-form-urlencoded') |
| 36 | |
| 37 | if (normalizedOptions.defaultCharset !== 'utf-8' && normalizedOptions.defaultCharset !== 'iso-8859-1') { |
| 38 | throw new TypeError('option defaultCharset must be either utf-8 or iso-8859-1') |
| 39 | } |
| 40 | |
| 41 | // create the appropriate query parser |
| 42 | const parse = createQueryParser(options) |
| 43 | |
| 44 | const readOptions = { |
| 45 | ...normalizedOptions, |
| 46 | // assert charset |
| 47 | isValidCharset: (charset) => charset === 'utf-8' || charset === 'iso-8859-1' |
| 48 | } |
| 49 | |
| 50 | return function urlencodedParser (req, res, next) { |
| 51 | read(req, res, next, parse, debug, readOptions) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get the extended query parser. |
nothing calls this directly
no test coverage detected
searching dependent graphs…