MCPcopy
hub / github.com/expressjs/body-parser / urlencoded

Function urlencoded

lib/types/urlencoded.js:34–53  ·  view source on GitHub ↗

* Create a middleware to parse urlencoded bodies. * * @param {Object} [options] * @returns {Function} * @public

(options)

Source from the content-addressed store, hash-verified

32 * @public
33 */
34function 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.

Callers

nothing calls this directly

Calls 3

normalizeOptionsFunction · 0.85
createQueryParserFunction · 0.85
readFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…