summaryrefslogtreecommitdiff
path: root/test_util/src/lib.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-10-26 07:17:58 +1100
committerGitHub <noreply@github.com>2020-10-26 07:17:58 +1100
commit3d19fb493b82a8ab9b3fd0fa923fc81fd68acb4e (patch)
tree8080a1f05c43c972db1a0ecbc0a39ed74c78f419 /test_util/src/lib.rs
parent95854b88ad4a67afb885322c70bb424352bca49e (diff)
fix(cli): properly handle roots with extensions that don't match media type (#8114)
Diffstat (limited to 'test_util/src/lib.rs')
-rw-r--r--test_util/src/lib.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs
index 832c40f59..eab8bcac6 100644
--- a/test_util/src/lib.rs
+++ b/test_util/src/lib.rs
@@ -420,6 +420,19 @@ pub async fn run_all_servers() {
HeaderValue::from_static("application/typescript"),
);
res
+ }))
+ .or(warp::path!("cli"/"tests"/"subdir"/"no_js_ext@1.0.0").map(|| {
+ let mut res = Response::new(Body::from(
+ r#"import { printHello } from "./mod2.ts";
+ printHello();
+ "#,
+ ));
+ let h = res.headers_mut();
+ h.insert(
+ "Content-type",
+ HeaderValue::from_static("application/javascript"),
+ );
+ res
}));
let content_type_handler = warp::any()
@@ -522,7 +535,7 @@ fn custom_headers(path: warp::path::Peek, f: warp::fs::File) -> Box<dyn Reply> {
Some("application/x-www-form-urlencoded")
} else if p.contains("unknown_ext") || p.contains("no_ext") {
Some("text/typescript")
- } else if p.contains("mismatch_ext") {
+ } else if p.contains("mismatch_ext") || p.contains("no_js_ext") {
Some("text/javascript")
} else if p.ends_with(".ts") || p.ends_with(".tsx") {
Some("application/typescript")