Skip to content

Commit 37f36a2

Browse files
deps: update content-type and type-is (#728)
* Upgrade "content-type" * Bump type-is * Update lib/utils.js Co-authored-by: Phillip Barta <barta.phillip@gmail.com> * Update lib/utils.js Co-authored-by: Phillip Barta <barta.phillip@gmail.com> * update HISTORY.md --------- Co-authored-by: Phillip Barta <barta.phillip@gmail.com>
1 parent e1c244b commit 37f36a2

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

HISTORY.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ unreleased
44
* fix: use static exports instead of lazy getters to improve ESM compatibility
55
* feat: add subpath exports for individual parsers
66
* deps:
7+
* content-type@^2.0.0
78
* http-errors@^2.0.1
89
* iconv-lite^0.7.2
910
* qs@^6.15.0
1011
* raw-body@^3.0.1
12+
* type-is@^2.1.0
1113

1214
2.2.2 / 2026-01-07
1315
=========================
@@ -19,11 +21,11 @@ unreleased
1921
=========================
2022

2123
* Security fix for [GHSA-wqch-xfxh-vrr4](https://github.com/expressjs/body-parser/security/advisories/GHSA-wqch-xfxh-vrr4)
22-
* deps:
24+
* deps:
2325
* type-is@^2.0.1
2426
* iconv-lite@^0.7.0
2527
* Handle split surrogate pairs when encoding UTF-8
26-
* Avoid false positives in `encodingExists` by using prototype-less objects
28+
* Avoid false positives in `encodingExists` by using prototype-less objects
2729
* raw-body@^3.0.1
2830
* debug@^4.4.3
2931

@@ -117,7 +119,7 @@ This incorporates all changes after 1.19.1 up to 1.20.2.
117119
* deps: qs@6.13.0
118120
* add `depth` option to customize the depth level in the parser
119121
* IMPORTANT: The default `depth` level for parsing URL-encoded data is now `32` (previously was `Infinity`)
120-
122+
121123
1.20.2 / 2023-02-21
122124
===================
123125

lib/utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ module.exports = {
2525
* @private
2626
*/
2727
function getCharset (req) {
28-
try {
29-
return (contentType.parse(req).parameters.charset || '').toLowerCase()
30-
} catch {
31-
return undefined
32-
}
28+
var header = req.headers['content-type']
29+
if (!header) return undefined
30+
return contentType.parse(header).parameters.charset?.toLowerCase()
3331
}
3432

3533
/**

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
},
2828
"dependencies": {
2929
"bytes": "^3.1.2",
30-
"content-type": "^1.0.5",
30+
"content-type": "^2.0.0",
3131
"debug": "^4.4.3",
3232
"http-errors": "^2.0.1",
3333
"iconv-lite": "^0.7.2",
3434
"on-finished": "^2.4.1",
3535
"qs": "^6.15.0",
3636
"raw-body": "^3.0.2",
37-
"type-is": "^2.0.1"
37+
"type-is": "^2.1.0"
3838
},
3939
"devDependencies": {
4040
"eslint": "^8.57.1",

0 commit comments

Comments
 (0)