util: pass invalidSubtypeIndex instead of trimmedSubtype to error

PR-URL: https://github.com/nodejs/node/pull/51264
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
This commit is contained in:
Gaurish Sethia 2023-12-25 09:59:00 +05:30 committed by GitHub
parent 26d39e875f
commit 6a1abd2c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,7 @@ function parseTypeAndSubtype(str) {
const invalidSubtypeIndex = SafeStringPrototypeSearch(trimmedSubtype,
NOT_HTTP_TOKEN_CODE_POINT);
if (trimmedSubtype === '' || invalidSubtypeIndex !== -1) {
throw new ERR_INVALID_MIME_SYNTAX('subtype', str, trimmedSubtype);
throw new ERR_INVALID_MIME_SYNTAX('subtype', str, invalidSubtypeIndex);
}
const subtype = toASCIILower(trimmedSubtype);
return [