diff --git a/lib/read.js b/lib/read.js index d1f3f480..7bb34942 100644 --- a/lib/read.js +++ b/lib/read.js @@ -17,7 +17,7 @@ var iconv = require('iconv-lite') var onFinished = require('on-finished') var zlib = require('node:zlib') var hasBody = require('type-is').hasBody -var { getCharset } = require('./utils') +var contentType = require('content-type') /** * Module exports. @@ -245,3 +245,18 @@ function dump (req, callback) { req.resume() } } + +/** + * Get the charset of a request. + * + * @param {Object} req + * @returns {string | undefined} + * @private + */ +function getCharset (req) { + try { + return contentType.parse(req).parameters.charset?.toLowerCase() + } catch { + return undefined + } +} diff --git a/lib/utils.js b/lib/utils.js index e0bf9741..cc8b4f9c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -5,33 +5,16 @@ */ var bytes = require('bytes') -var contentType = require('content-type') var 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) { - try { - return (contentType.parse(req).parameters.charset || '').toLowerCase() - } catch { - return undefined - } -} - /** * Get the simple type checker. *