SIGN IN SIGN UP
honojs / hono UNCLAIMED

Web framework built on Web Standards

0 0 77 TypeScript

fix(mime): specify charset parameter per MIME type instead of mechanical detection (#4912)

Per #4510:

- Inline `; charset=utf-8` in `_baseMimes` for all text/* entries plus
  `image/svg+xml`, `application/xhtml+xml`, and `application/xml`,
  which are XML-based formats that benefit from an explicit charset.
- Drop the `if (mimeType.startsWith("text"))` block in `getMimeType`;
  the charset now lives in the data, not in the lookup logic. Output
  for text types is unchanged (still "text/<sub>; charset=utf-8").
- Update `getExtension` to compare the base type (the part before the
  first `;`), so callers can pass either a raw type ("text/html") or
  one with parameters ("text/html; charset=utf-8") and still get the
  correct extension back.

Tests: 5 mime.test.ts cases pass (3 existing + 2 new) covering the new
charset values for svg/xhtml/xml/ics/mjs/css/csv and getExtension with
parameters.

Closes #4510
R
Renato Grasso committed
a192df0844724aeaf5cbc6f1ea2f8425d3f8a86a
Parent: cf6ef70
Committed by GitHub <noreply@github.com> on 5/22/2026, 9:01:10 AM