summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-07-18 15:01:44 -0400
committerGitHub <noreply@github.com>2019-07-18 15:01:44 -0400
commita37bc0088f9de76108fe0bd9243c794b413d73cf (patch)
treef9e9b321cea3d75c371a54fcd5043cdabc6dcf6f
parent55ca0f09cb50f8bc6b0590a9a88febc41f91e51b (diff)
Remove hacky normalize_path (#2660)
-rw-r--r--cli/deno_dir.rs32
-rw-r--r--tests/022_info_flag.out2
2 files changed, 11 insertions, 23 deletions
diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs
index d3f53b2e6..91a39543d 100644
--- a/cli/deno_dir.rs
+++ b/cli/deno_dir.rs
@@ -61,20 +61,6 @@ impl SourceFile {
}
}
-// TODO(bartlomieju): this should be removed, but integration test 022_info_flag depends on
-// using "/" (forward slashes) or doesn't match output on Windows
-fn normalize_path(path: &Path) -> PathBuf {
- let s = String::from(path.to_str().unwrap());
- let normalized_string = if cfg!(windows) {
- // TODO This isn't correct. Probbly should iterate over components.
- s.replace("\\", "/")
- } else {
- s
- };
-
- PathBuf::from(normalized_string)
-}
-
pub type SourceFileFuture =
dyn Future<Item = SourceFile, Error = ErrBox> + Send;
@@ -353,11 +339,12 @@ impl DenoDir {
Err(e) => return Err(e.into()),
};
+ let media_type = map_content_type(&filepath, None);
Ok(SourceFile {
url: module_url.clone(),
redirect_source_url: None,
- filename: normalize_path(&filepath),
- media_type: map_content_type(&filepath, None),
+ filename: filepath,
+ media_type,
source_code,
})
}
@@ -420,14 +407,15 @@ impl DenoDir {
}
Ok(c) => c,
};
+ let media_type = map_content_type(
+ &filepath,
+ source_code_headers.mime_type.as_ref().map(String::as_str),
+ );
Ok(Some(SourceFile {
url: module_url.clone(),
redirect_source_url: maybe_initial_module_url,
- filename: normalize_path(&filepath),
- media_type: map_content_type(
- &filepath,
- source_code_headers.mime_type.as_ref().map(String::as_str),
- ),
+ filename: filepath,
+ media_type,
source_code,
}))
}
@@ -512,7 +500,7 @@ impl DenoDir {
let source_file = SourceFile {
url: module_url,
redirect_source_url: maybe_initial_module_url,
- filename: normalize_path(&filepath),
+ filename: filepath,
media_type,
source_code: source.as_bytes().to_owned(),
};
diff --git a/tests/022_info_flag.out b/tests/022_info_flag.out
index 329e07b6d..519e7cf6b 100644
--- a/tests/022_info_flag.out
+++ b/tests/022_info_flag.out
@@ -1,4 +1,4 @@
-local: [WILDCARD]deps/http/127.0.0.1_PORT4545/tests/019_media_types.ts
+local: [WILDCARD]019_media_types.ts
type: TypeScript
compiled: [WILDCARD].js
map: [WILDCARD].js.map