From 791c8016f996f16bf25ad7103a6f247f8324b99d Mon Sep 17 00:00:00 2001 From: Phillip Barta Date: Mon, 23 Feb 2026 19:15:16 +0100 Subject: [PATCH] refactor: move getCharset helper to only usage --- lib/read.js | 15 ++++++++++++++- lib/utils.js | 15 --------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/read.js b/lib/read.js index bf1a1df4..cb624180 100644 --- a/lib/read.js +++ b/lib/read.js @@ -17,7 +17,7 @@ const iconv = require('iconv-lite') const onFinished = require('on-finished') const zlib = require('node:zlib') const hasBody = require('type-is').hasBody -const { getCharset } = require('./utils') +const contentType = require('content-type') /** * Module exports. @@ -245,3 +245,16 @@ function dump (req, callback) { req.resume() } } + +/** + * 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() +} diff --git a/lib/utils.js b/lib/utils.js index 7a0dda43..d92075ec 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -5,31 +5,16 @@ */ 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. *