Skip to content

Commit

Permalink
(v3.x) perf: only check for isEssence once in RegExp for content-type…
Browse files Browse the repository at this point in the history
…-parser (#4481)
  • Loading branch information
Uzlopak authored and climba03003 committed Jan 5, 2023
1 parent 6453645 commit 23625d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/contentTypeParser.js
Expand Up @@ -72,6 +72,7 @@ ContentTypeParser.prototype.add = function (contentType, opts, parserFn) {
if (contentTypeIsString) {
this.parserList.unshift(new ParserListItem(contentType))
} else {
contentType.isEssence = contentType.source.indexOf(';') === -1
this.parserRegExpList.unshift(contentType)
}
this.customParsers.set(contentType.toString(), parser)
Expand Down Expand Up @@ -395,7 +396,7 @@ function compareContentType (contentType, parserListItem) {
}

function compareRegExpContentType (contentType, essenceMIMEType, regexp) {
if (regexp.source.indexOf(';') === -1) {
if (regexp.isEssence) {
// we do essence check
return regexp.test(essenceMIMEType)
} else {
Expand Down

0 comments on commit 23625d3

Please sign in to comment.