Skip to content

Commit

Permalink
perf: only check for isEssence once in RegExp for content-type-parser (
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Dec 24, 2022
1 parent 4bde0e0 commit 897360a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/contentTypeParser.js
Expand Up @@ -70,6 +70,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 @@ -389,7 +390,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 897360a

Please sign in to comment.