Repository navigation
Add node:util MIMEType.parse() - #8108
Merged
Merged
Conversation
|
This pull request was not reviewed automatically because its author does not have write access to this repository. A maintainer with write access can start a review by commenting |
jasnell
approved these changes
Oct 31, 2026
Contributor
Author
|
The two red bazel jobs are clang-tidy failures on C++ files this PR does not touch (same on #8116); the mimetype wd_test passed. |
Collaborator
|
Can I ask you to rebase on latest |
JosephDoUrden
force-pushed
the
feat/mimetype-parse
branch
from
November 2, 2026 18:29
33743b8 to
90dcc87
Compare
Contributor
Author
|
Rebased on main. |
JosephDoUrden
force-pushed
the
feat/mimetype-parse
branch
2 times, most recently
from
November 5, 2026 12:51
49a1c4b to
dc89d9a
Compare
Contributor
Author
|
rebased onto today's main; the workflows are waiting for approval. |
Contributor
Author
|
unrelated flakes, rerun please? |
JosephDoUrden
force-pushed
the
feat/mimetype-parse
branch
from
November 13, 2026 15:01
dc89d9a to
4b98ac6
Compare
Node.js 24.21 added the static MIMEType.parse(string): it parses like the constructor but returns null instead of throwing when the input is not a valid MIME type. The argument goes through ToString even when it is missing, so MIMEType.parse() with no argument returns null, while a Symbol still throws. The parsed record is adopted directly rather than parsed a second time. Compatibility: this adds a static method to node:util's MIMEType at every compatibility date, without a flag, which we accept. The only observable change is that code feature-detecting MIMEType.parse now takes the native branch. Fixes cloudflare#7663
JosephDoUrden
force-pushed
the
feat/mimetype-parse
branch
from
November 26, 2026 17:51
4b98ac6 to
a398e9f
Compare
Contributor
Author
|
rebased onto main after #8868 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7663.
Adds the static
MIMEType.parse(string)that Node.js 24.21 / 26.8 added tonode:util: same parser as the constructor,nullinstead of a throw when the input is not a valid MIME type. The argument goes through ToString even when it is missing, soMIMEType.parse()returnsnull(the constructor throws for a missing argument), and a Symbol still throws, as in Node. The already-parsed record is adopted through the module-private tokenMIMEParamsalready uses, so nothing is parsed twice.Tests:
test_static_parseruns every case inparseCasesthroughparse()and checks null exactly where the constructor throws and an equalMIMETypeotherwise, plus the coercion cases, lone surrogates, that the result is live (params.setand setters write through),parse.length, andparseinside the patched-builtins test.I could not run bazel locally for this one (disk), so the wd_test runs here on CI; the module and the test file pass under a Node harness that bundles
internal_mime.tsdirectly.