Skip to content

util: add MIME utilities

Rodrigo Muino Tomonari requested to merge github/fork/bmeck/mime-module into main
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This adds a new module for handling MIME types. It is standalone based upon the WHATWG MIME standards , but is more intended to open up APIs that wish to use MIME for coordinating content types. I have left out the various sniffing for content bodies until a future date as I believe that is a longer discussion than just parsing and serializing. The API is based upon URL and URLSearchParams and intentionally allows us to expand MIMEParams for dealing with multiple parameters with the same name (.getAll / .append etc.).

This PR does not introduce any MIME databases for file paths.

The MIMEParams are not exposed as a string getter / setter, unlike url.search. These manipulations can be done using the map interface provided, and accessors can be added in a follow on if seen as desirable.

Test cases were pulled from web platform tests , but we don't have a well documented process for keeping such fixtures in sync so I have not done anything except vendor them for now, similar to https://github.com/nodejs/node/blob/master/test/fixtures/url-tests.js .

Merge request reports

Loading