Skip to content

Commit

Permalink
perf: prevent internal throw when missing charset
Browse files Browse the repository at this point in the history
closes #250
  • Loading branch information
jdspugh authored and dougwilson committed Aug 5, 2017
1 parent fb5b8ec commit 9437df9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Expand Up @@ -15,6 +15,7 @@ unreleased
- Use `http-errors` for standard emitted errors
- deps: bytes@2.5.0
- deps: iconv-lite@0.4.18
* perf: prevent internal `throw` when missing charset

1.17.2 / 2017-05-17
===================
Expand Down
2 changes: 1 addition & 1 deletion lib/types/json.js
Expand Up @@ -154,7 +154,7 @@ function firstchar (str) {

function getCharset (req) {
try {
return contentType.parse(req).parameters.charset.toLowerCase()
return (contentType.parse(req).parameters.charset || '').toLowerCase()
} catch (e) {
return undefined
}
Expand Down
2 changes: 1 addition & 1 deletion lib/types/text.js
Expand Up @@ -101,7 +101,7 @@ function text (options) {

function getCharset (req) {
try {
return contentType.parse(req).parameters.charset.toLowerCase()
return (contentType.parse(req).parameters.charset || '').toLowerCase()
} catch (e) {
return undefined
}
Expand Down
2 changes: 1 addition & 1 deletion lib/types/urlencoded.js
Expand Up @@ -171,7 +171,7 @@ function extendedparser (options) {

function getCharset (req) {
try {
return contentType.parse(req).parameters.charset.toLowerCase()
return (contentType.parse(req).parameters.charset || '').toLowerCase()
} catch (e) {
return undefined
}
Expand Down

0 comments on commit 9437df9

Please sign in to comment.