MCPcopy Create free account
hub / github.com/expressjs/body-parser / simpleparser

Function simpleparser

lib/types/urlencoded.js:244–271  ·  view source on GitHub ↗

* Get the simple query parser. * * @param {object} options

(options)

Source from the content-addressed store, hash-verified

242 */
243
244function simpleparser (options) {
245 var parameterLimit = options.parameterLimit !== undefined
246 ? options.parameterLimit
247 : 1000
248 var parse = parser('querystring')
249
250 if (isNaN(parameterLimit) || parameterLimit < 1) {
251 throw new TypeError('option parameterLimit must be a positive number')
252 }
253
254 if (isFinite(parameterLimit)) {
255 parameterLimit = parameterLimit | 0
256 }
257
258 return function queryparse (body) {
259 var paramCount = parameterCount(body, parameterLimit)
260
261 if (paramCount === undefined) {
262 debug('too many parameters')
263 throw createError(413, 'too many parameters', {
264 type: 'parameters.too.many'
265 })
266 }
267
268 debug('parse urlencoding')
269 return parse(body, undefined, undefined, { maxKeys: parameterLimit })
270 }
271}
272
273/**
274 * Get the simple type checker.

Callers 1

urlencodedFunction · 0.85

Calls 3

parserFunction · 0.85
parameterCountFunction · 0.85
parseFunction · 0.70

Tested by

no test coverage detected