Skip to content

Commit 227a469

Browse files
authored
Add minimize a supported MIME type for Fetch and Resource Timing
See WebKit/standards-positions#88 (comment) for rationale. whatwg/fetch#1481 will be updated to call this.
1 parent ca4f6b8 commit 227a469

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

mimesniff.bs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,40 @@ confusion with the use of <i>media type</i> as described in <cite>Media Queries<
198198
<p>A <a>MIME type</a> is <dfn export>supported by the user agent</dfn> if the user agent has the
199199
capability to interpret a <a>resource</a> of that <a>MIME type</a> and present it to the user.
200200

201-
<p class=XXX>This needs more work. See
201+
<p class=XXX>Ideally this would be more precise. See
202202
<a href=https://github.com/w3c/preload/issues/113>w3c/preload #113</a>.
203203

204+
<div algorithm>
205+
<p>To <dfn export>minimize a supported MIME type</dfn> given a <a>MIME type</a> <var>mimeType</var>,
206+
run these steps. They return an <a>ASCII string</a>.
207+
208+
<ol>
209+
<li><p>If <var>mimeType</var> is a <a>JavaScript MIME type</a>, then return
210+
"<code>text/javascript</code>".
211+
212+
<li><p>If <var>mimeType</var> is a <a>JSON MIME type</a>, then return
213+
"<code>application/json</code>".
214+
215+
<li>
216+
<p>If <var>mimeType</var>'s <a for="MIME type">essence</a> is "<code>image/svg+xml</code>", then
217+
return "<code>image/svg+xml</code>".
218+
219+
<p class=note>SVG is worth distinguishing from other <a>XML MIME types</a>.
220+
221+
<li><p>If <var>mimeType</var> is an <a>XML MIME type</a>, then return
222+
"<code>application/xml</code>".
223+
224+
<li><p>If <var>mimeType</var> is <a>supported by the user agent</a>, then return
225+
<var>mimeType</var>'s <a for="MIME type">essence</a>.
226+
227+
<li><p>Return the empty string.
228+
</ol>
229+
230+
<p class=note>The goal of this algorithm is to allow the caller to distinguish MIME types with
231+
different processing models, such as those for GIF and PNG, but otherwise provide as little
232+
information as possible.
233+
</div>
234+
204235

205236
<h3 id=mime-type-writing>MIME type writing</h3>
206237

0 commit comments

Comments
 (0)