From a720e70d479d56693bd1f9d531c1ce6b871cb012 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 27 Apr 2023 17:10:08 +0200 Subject: [PATCH] Add minimize a supported MIME type for Fetch and Resource Timing See https://github.com/WebKit/standards-positions/issues/88#issuecomment-1525796885 for rationale. https://github.com/whatwg/fetch/pull/1481 will be updated to call this. --- mimesniff.bs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/mimesniff.bs b/mimesniff.bs index eef18c4..cbf26cd 100644 --- a/mimesniff.bs +++ b/mimesniff.bs @@ -198,9 +198,35 @@ confusion with the use of media type as described in Media Queries<

A MIME type is supported by the user agent if the user agent has the capability to interpret a resource of that MIME type and present it to the user. -

This needs more work. See +

Ideally this would be more precise. See w3c/preload #113. +

To minimize a supported MIME type given a MIME type mimeType, +run these steps. They return an ASCII string. + +

    +
  1. If mimeType is a JavaScript MIME type, then return + "text/javascript". + +

  2. If mimeType is a JSON MIME type, then return + "application/json". + +

  3. If mimeType's essence is "image/svg+xml", + then return "image/svg+xml". + +

  4. If mimeType is an XML MIME type, then return + "application/xml". + +

  5. If mimeType is supported by the user agent, then return + mimeType's essence. + +

  6. Return the empty string. +

+ +

The goal of this algorithm is to allow the caller to distinguish MIME types with +different processing models, such as those for GIF and PNG, but otherwise provide as little +information as possible. +

MIME type writing