Skip to content

Commit

Permalink
update media_types
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan committed Apr 6, 2020
1 parent 9eefba9 commit 5617187
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
19 changes: 8 additions & 11 deletions constants.ts
Expand Up @@ -65,9 +65,6 @@ export namespace MIME {
ApplicationJavaScript = "application/javascript",
ApplicationJavaScriptCharsetUTF8 = ApplicationJavaScript + "; " +
charsetUTF8,
ApplicationTypeScript = "application/typescript",
ApplicationTypeScriptCharsetUTF8 = ApplicationJavaScript + "; " +
charsetUTF8,
ApplicationXML = "application/xml",
ApplicationXMLCharsetUTF8 = ApplicationXML + "; " + charsetUTF8,
TextMarkdown = "text/markdown",
Expand All @@ -85,16 +82,16 @@ export namespace MIME {
OctetStream = "application/octet-stream";

export const DB: Record<string, string | undefined> = {
".md": TextMarkdown,
".html": TextHTML,
".htm": TextHTML,
".md": TextMarkdownCharsetUTF8,
".html": TextHTMLCharsetUTF8,
".htm": TextHTMLCharsetUTF8,
".json": ApplicationJSON,
".map": ApplicationJSON,
".txt": TextPlain,
".ts": ApplicationTypeScript,
".tsx": ApplicationTypeScript,
".js": ApplicationJavaScript,
".jsx": ApplicationJavaScript,
".txt": TextPlainCharsetUTF8,
".ts": ApplicationJavaScriptCharsetUTF8,
".tsx": ApplicationJavaScriptCharsetUTF8,
".js": ApplicationJavaScriptCharsetUTF8,
".jsx": ApplicationJavaScriptCharsetUTF8,
".gz": ApplicationGZip,
};
}
2 changes: 1 addition & 1 deletion context_test.ts
Expand Up @@ -66,7 +66,7 @@ test(async function FileResponse(): Promise<void> {
await c.file("./mod.ts");
assertEquals(
c.response.headers!.get("Content-Type"),
"application/typescript",
"application/javascript; charset=UTF-8",
);
});

Expand Down
28 changes: 20 additions & 8 deletions util_test.ts
Expand Up @@ -5,15 +5,27 @@ const { test } = Deno;

test(function UtilContentType(): void {
assertEquals(contentType("/path/to/file"), undefined);
assertEquals(contentType("/path/to/file.md"), MIME.TextMarkdown);
assertEquals(contentType("/path/to/file.html"), MIME.TextHTML);
assertEquals(contentType("/path/to/file.htm"), MIME.TextHTML);
assertEquals(contentType("/path/to/file.md"), MIME.TextMarkdownCharsetUTF8);
assertEquals(contentType("/path/to/file.html"), MIME.TextHTMLCharsetUTF8);
assertEquals(contentType("/path/to/file.htm"), MIME.TextHTMLCharsetUTF8);
assertEquals(contentType("/path/to/file.json"), MIME.ApplicationJSON);
assertEquals(contentType("/path/to/file.map"), MIME.ApplicationJSON);
assertEquals(contentType("/path/to/file.txt"), MIME.TextPlain);
assertEquals(contentType("/path/to/file.ts"), MIME.ApplicationTypeScript);
assertEquals(contentType("/path/to/file.tsx"), MIME.ApplicationTypeScript);
assertEquals(contentType("/path/to/file.js"), MIME.ApplicationJavaScript);
assertEquals(contentType("/path/to/file.jsx"), MIME.ApplicationJavaScript);
assertEquals(contentType("/path/to/file.txt"), MIME.TextPlainCharsetUTF8);
assertEquals(
contentType("/path/to/file.ts"),
MIME.ApplicationJavaScriptCharsetUTF8,
);
assertEquals(
contentType("/path/to/file.tsx"),
MIME.ApplicationJavaScriptCharsetUTF8,
);
assertEquals(
contentType("/path/to/file.js"),
MIME.ApplicationJavaScriptCharsetUTF8,
);
assertEquals(
contentType("/path/to/file.jsx"),
MIME.ApplicationJavaScriptCharsetUTF8,
);
assertEquals(contentType("/path/to/file.gz"), MIME.ApplicationGZip);
});

0 comments on commit 5617187

Please sign in to comment.