INNER CODE UNIT · JavaScript

normalizeOptions

expressjs/body-parser · lib/utils.js:39

function normalizeOptions (options, defaultType) {
  if (!defaultType) {
    // Parsers must define a default content type
    throw new TypeError('defaultType must be provided')
  }

  const inflate = options?.inflate !== false
  const limit = typeof options?.limit === 'undefined' || options?.limit === null
    ? 102400 // 100kb default
    : bytes.parse(options.limit)
  const type = options?.type || defaultType
  const verify = options?.verify || false
  const defaultCharset = options?.defaultCharset || 'utf-8'

  if (limit === null) {
    throw new TypeError(`option limit "${String(options.limit)}" is invalid`)
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…