Skip to content

util: fix wrong argument of `ERR_INVALID_MIME_SYNTAX`

Third argument of ERR_INVALID_MIME_SYNTAX is invalid index (not string).

https://github.com/nodejs/node/blob/cde3296f5f6c7054c0bcb1dd9e1ee8a43ec3b3f1/lib/internal/errors.js#L1419-L1422

When I tested with below example,

const { MIMEType } = require('node:util');
const myMIME = new MIMEType('text/javascript,');

Before

node:internal/mime:73
    throw new ERR_INVALID_MIME_SYNTAX('subtype', str, trimmedSubtype);
    ^

TypeError [ERR_INVALID_MIME_SYNTAX]: The MIME syntax for a subtype in "text/javascript," is invalid at javascript,
    at parseTypeAndSubtype (node:internal/mime:73:11)
    at new MIMEType (node:internal/mime:332:18)

After

node:internal/mime:73
    throw new ERR_INVALID_MIME_SYNTAX('subtype', str, invalidSubtypeIndex);
    ^

TypeError [ERR_INVALID_MIME_SYNTAX]: The MIME syntax for a subtype in "text/javascript," is invalid at 10
    at parseTypeAndSubtype (node:internal/mime:73:11)
    at new MIMEType (node:internal/mime:332:18)

Merge request reports

Loading