summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2018-10-27 17:26:42 -0700
committerRyan Dahl <ry@tinyclouds.org>2018-10-28 11:18:53 -0700
commita68403d09006af3e7f75aacb9e818ce3bcf60b13 (patch)
tree26ba8f95660697ef9d20a6f4d6fdccf327444f22
parentda959e8c878382ce3417ab61db8ccf1ae9a660fa (diff)
Add application/x-typescript mime type support
-rw-r--r--src/deno_dir.rs7
-rw-r--r--tests/019_media_types.ts2
-rw-r--r--tests/019_media_types.ts.out3
-rw-r--r--tests/subdir/mt_application_x_typescript.t4.ts1
-rwxr-xr-xtools/http_server.py2
5 files changed, 13 insertions, 2 deletions
diff --git a/src/deno_dir.rs b/src/deno_dir.rs
index d0c85d134..b0e9ba43c 100644
--- a/src/deno_dir.rs
+++ b/src/deno_dir.rs
@@ -794,7 +794,8 @@ fn map_content_type(path: &Path, content_type: Option<&str>) -> msg::MediaType {
"application/typescript"
| "text/typescript"
| "video/vnd.dlna.mpeg-tts"
- | "video/mp2t" => msg::MediaType::TypeScript,
+ | "video/mp2t"
+ | "application/x-typescript" => msg::MediaType::TypeScript,
"application/javascript"
| "text/javascript"
| "application/ecmascript"
@@ -858,6 +859,10 @@ fn test_map_content_type() {
msg::MediaType::TypeScript
);
assert_eq!(
+ map_content_type(Path::new("foo/bar"), Some("application/x-typescript")),
+ msg::MediaType::TypeScript
+ );
+ assert_eq!(
map_content_type(Path::new("foo/bar"), Some("application/javascript")),
msg::MediaType::JavaScript
);
diff --git a/tests/019_media_types.ts b/tests/019_media_types.ts
index dbd951b3e..90eca80bf 100644
--- a/tests/019_media_types.ts
+++ b/tests/019_media_types.ts
@@ -6,6 +6,7 @@
import { loaded as loadedTs1 } from "http://localhost:4545/tests/subdir/mt_text_typescript.t1.ts";
import { loaded as loadedTs2 } from "http://localhost:4545/tests/subdir/mt_video_vdn.t2.ts";
import { loaded as loadedTs3 } from "http://localhost:4545/tests/subdir/mt_video_mp2t.t3.ts";
+import { loaded as loadedTs4 } from "http://localhost:4545/tests/subdir/mt_application_x_typescript.t4.ts";
import { loaded as loadedJs1 } from "http://localhost:4545/tests/subdir/mt_text_javascript.j1.js";
import { loaded as loadedJs2 } from "http://localhost:4545/tests/subdir/mt_application_ecmascript.j2.js";
import { loaded as loadedJs3 } from "http://localhost:4545/tests/subdir/mt_text_ecmascript.j3.js";
@@ -16,6 +17,7 @@ console.log(
loadedTs1,
loadedTs2,
loadedTs3,
+ loadedTs4,
loadedJs1,
loadedJs2,
loadedJs3,
diff --git a/tests/019_media_types.ts.out b/tests/019_media_types.ts.out
index b127519b5..31f5d8de0 100644
--- a/tests/019_media_types.ts.out
+++ b/tests/019_media_types.ts.out
@@ -1,8 +1,9 @@
Downloading http://localhost:4545/tests/subdir/mt_text_typescript.t1.ts
Downloading http://localhost:4545/tests/subdir/mt_video_vdn.t2.ts
Downloading http://localhost:4545/tests/subdir/mt_video_mp2t.t3.ts
+Downloading http://localhost:4545/tests/subdir/mt_application_x_typescript.t4.ts
Downloading http://localhost:4545/tests/subdir/mt_text_javascript.j1.js
Downloading http://localhost:4545/tests/subdir/mt_application_ecmascript.j2.js
Downloading http://localhost:4545/tests/subdir/mt_text_ecmascript.j3.js
Downloading http://localhost:4545/tests/subdir/mt_application_x_javascript.j4.js
-success true true true true true true true
+success true true true true true true true true
diff --git a/tests/subdir/mt_application_x_typescript.t4.ts b/tests/subdir/mt_application_x_typescript.t4.ts
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/tests/subdir/mt_application_x_typescript.t4.ts
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/tools/http_server.py b/tools/http_server.py
index 011f3c31a..065635c6f 100755
--- a/tools/http_server.py
+++ b/tools/http_server.py
@@ -22,6 +22,8 @@ class ContentTypeHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
return "video/vnd.dlna.mpeg-tts"
if ".t3." in path:
return "video/mp2t"
+ if ".t4." in path:
+ return "application/x-typescript"
if ".j1." in path:
return "text/javascript"
if ".j2." in path: