mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
Remove hacky normalize_path (#2660)
This commit is contained in:
parent
55ca0f09cb
commit
a37bc0088f
2 changed files with 11 additions and 23 deletions
|
@ -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(),
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue