diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js index 687745f8..0ce42a0d 100644 --- a/lib/types/urlencoded.js +++ b/lib/types/urlencoded.js @@ -188,13 +188,13 @@ function createQueryParser (options, extended) { * Get the charset of a request. * * @param {object} req + * @returns {(string|undefined)} * @api private */ - function getCharset (req) { try { - return (contentType.parse(req).parameters.charset || '').toLowerCase() - } catch (e) { + return contentType.parse(req).parameters.charset?.toLowerCase() + } catch { return undefined } }