aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/body-parser/lib/utils.js
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-08-09 10:54:08 +0000
committerpack <pack@packgekko.xyz>2026-08-09 10:54:08 +0000
commitd3adc16a08d95d6e331de55d7d3bf05a66a874a8 (patch)
treea2dabd199501e67c547c2ce79e1374ca3aa55443 /node_modules/body-parser/lib/utils.js
parent55a4f1fc869e41aca748c63d3018f0448b1606e0 (diff)
downloadcrud-d3adc16a08d95d6e331de55d7d3bf05a66a874a8.tar.gz
stop tracking node_modules/
Diffstat (limited to '')
-rw-r--r--node_modules/body-parser/lib/utils.js100
1 files changed, 0 insertions, 100 deletions
diff --git a/node_modules/body-parser/lib/utils.js b/node_modules/body-parser/lib/utils.js
deleted file mode 100644
index 7a0dda4..0000000
--- a/node_modules/body-parser/lib/utils.js
+++ /dev/null
@@ -1,100 +0,0 @@
-'use strict'
-
-/**
- * Module dependencies.
- */
-
-const bytes = require('bytes')
-const contentType = require('content-type')
-const typeis = require('type-is')
-
-/**
- * Module exports.
- */
-module.exports = {
- getCharset,
- normalizeOptions,
- passthrough
-}
-
-/**
- * Get the charset of a request.
- *
- * @param {Object} req
- * @returns {string | undefined}
- * @private
- */
-function getCharset (req) {
- const header = req.headers['content-type']
- if (!header) return undefined
- return contentType.parse(header).parameters.charset?.toLowerCase()
-}
-
-/**
- * Get the simple type checker.
- *
- * @param {string | string[]} type
- * @returns {Function}
- * @private
- */
-function typeChecker (type) {
- return function checkType (req) {
- return Boolean(typeis(req, type))
- }
-}
-
-/**
- * Normalizes the common options for all parsers.
- *
- * @param {Object} options options to normalize
- * @param {string | string[] | Function} defaultType default content type(s) or a function to determine it
- * @returns {Object}
- * @private
- */
-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`)
- }
-
- if (verify !== false && typeof verify !== 'function') {
- throw new TypeError('option verify must be function')
- }
-
- // create the appropriate type checking function
- const shouldParse = typeof type !== 'function'
- ? typeChecker(type)
- : type
-
- return {
- inflate,
- limit,
- verify,
- defaultCharset,
- shouldParse
- }
-}
-
-/**
- * Passthrough function that returns input unchanged.
- * Used by parsers that don't need to transform the data.
- *
- * @param {*} value
- * @returns {*}
- * @private
- */
-function passthrough (value) {
- return value
-}