Skip to content

Commit

Permalink
debug 5
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Aug 11, 2019
1 parent 9edc8b6 commit cdc5122
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions cli/disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ impl DiskCache {
}
}
"file" => {
eprintln!("url file path {:?} {:?}", url.to_file_path(), url);
let path = url.to_file_path().unwrap();
let mut path_components = path.components();

if cfg!(target_os = "windows") {
if let Some(Component::Prefix(prefix_component)) =
path_components.next()
{
eprintln!("prefix component {:?}", prefix_component);
// Windows doesn't support ":" in filenames, so we need to extract disk prefix
// Example: file:///C:/deno/js/unit_test_runner.ts
// it should produce: file\c\deno\js\unit_test_runner.ts
Expand All @@ -62,8 +60,6 @@ impl DiskCache {
}
_ => {}
}
} else {
eprintln!("no prefix component {:?}", path);
}
}

Expand Down Expand Up @@ -150,14 +146,15 @@ mod tests {
"https://deno.land/std/http/file_server.ts",
"https/deno.land/std/http/file_server.ts",
),
(
"file:///std/http/file_server.ts",
"file/std/http/file_server.ts",
),
];

if cfg!(target_os = "windows") {
test_cases.push(("file:///D:/a/1/s/format.ts", "file/D/a/1/s/format.ts"))
test_cases.push(("file:///D:/a/1/s/format.ts", "file/D/a/1/s/format.ts"));
} else {
test_cases.push((
"file:///std/http/file_server.ts",
"file/std/http/file_server.ts",
));
}

for test_case in &test_cases {
Expand All @@ -171,24 +168,33 @@ mod tests {
fn test_get_cache_filename_with_extension() {
let cache = DiskCache::new(&PathBuf::from("foo"));

let test_cases = [
let mut test_cases = vec![
(
"http://deno.land/std/http/file_server.ts",
"js",
"http/deno.land/std/http/file_server.ts.js",
),
(
"file:///std/http/file_server",
"js",
"file/std/http/file_server.js",
),
(
"http://deno.land/std/http/file_server.ts",
"js.map",
"http/deno.land/std/http/file_server.ts.js.map",
),
];

if cfg!(target_os = "windows") {
test_cases.push((
"file:///D:/std/http/file_server",
"js",
"file/D/a/1/s/format.ts",
));
} else {
tes_cases.push((
"file:///std/http/file_server",
"js",
"file/std/http/file_server.js",
));
}

for test_case in &test_cases {
assert_eq!(
cache.get_cache_filename_with_extension(
Expand Down

0 comments on commit cdc5122

Please sign in to comment.