diff --git a/cli/disk_cache.rs b/cli/disk_cache.rs index afea71cd22..d6fb9866c2 100644 --- a/cli/disk_cache.rs +++ b/cli/disk_cache.rs @@ -1,4 +1,5 @@ use crate::fs as deno_fs; +use crate::http_cache::url_to_filename; use std::ffi::OsStr; use std::fs; use std::io; @@ -50,7 +51,7 @@ impl DiskCache { out.push(scheme); match scheme { - "http" | "https" | "wasm" => { + "wasm" => { let host = url.host_str().unwrap(); let host_port = match url.port() { // Windows doesn't support ":" in filenames, so we represent port using a @@ -64,6 +65,7 @@ impl DiskCache { out.push(path_seg); } } + "http" | "https" => out = url_to_filename(url), "file" => { let path = url.to_file_path().unwrap(); let mut path_components = path.components(); @@ -194,15 +196,15 @@ mod tests { let mut test_cases = vec![ ( "http://deno.land/std/http/file_server.ts", - "http/deno.land/std/http/file_server.ts", + "http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf", ), ( "http://localhost:8000/std/http/file_server.ts", - "http/localhost_PORT8000/std/http/file_server.ts", + "http/localhost_PORT8000/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf", ), ( "https://deno.land/std/http/file_server.ts", - "https/deno.land/std/http/file_server.ts", + "https/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf", ), ("wasm://wasm/d1c677ea", "wasm/wasm/d1c677ea"), ]; @@ -251,12 +253,12 @@ mod tests { ( "http://deno.land/std/http/file_server.ts", "js", - "http/deno.land/std/http/file_server.ts.js", + "http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf.js", ), ( "http://deno.land/std/http/file_server.ts", "js.map", - "http/deno.land/std/http/file_server.ts.js.map", + "http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf.js.map", ), ]; diff --git a/cli/tests/049_info_flag_script_jsx.out b/cli/tests/049_info_flag_script_jsx.out index ff4f04f3a6..fd5b511dc9 100644 --- a/cli/tests/049_info_flag_script_jsx.out +++ b/cli/tests/049_info_flag_script_jsx.out @@ -1,7 +1,7 @@ [WILDCARD] local: [WILDCARD]http[WILDCARD]127.0.0.1_PORT4545[WILDCARD] type: TypeScript -compiled: [WILDCARD]048_media_types_jsx.ts.js +compiled: [WILDCARD].js deps: http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts ├── http://localhost:4545/cli/tests/subdir/mt_text_typescript_tsx.t1.tsx diff --git a/cli/tests/054_info_local_imports.out b/cli/tests/054_info_local_imports.out index 32cfd85253..fdf2f44a63 100644 --- a/cli/tests/054_info_local_imports.out +++ b/cli/tests/054_info_local_imports.out @@ -1,6 +1,6 @@ local: [WILDCARD]005_more_imports.ts type: TypeScript -compiled: [WILDCARD]005_more_imports.ts.js +compiled: [WILDCARD].js deps: file://[WILDCARD]/005_more_imports.ts └─┬ file://[WILDCARD]/subdir/mod1.ts diff --git a/cli/tests/055_info_file_json.out b/cli/tests/055_info_file_json.out index 20bf94f3f5..08dc737909 100644 --- a/cli/tests/055_info_file_json.out +++ b/cli/tests/055_info_file_json.out @@ -1,7 +1,7 @@ { "local": "[WILDCARD]005_more_imports.ts", "fileType": "TypeScript", - "compiled": "[WILDCARD]005_more_imports.ts.js", + "compiled": "[WILDCARD].js", "map": null, "deps": [ "file://[WILDCARD]/005_more_imports.ts", diff --git a/cli/tests/import_file_with_colon.ts b/cli/tests/import_file_with_colon.ts new file mode 100644 index 0000000000..5a2bbceb60 --- /dev/null +++ b/cli/tests/import_file_with_colon.ts @@ -0,0 +1 @@ +import "http://localhost:4545/cli/tests/subdir/file_with_:_in_name.ts"; diff --git a/cli/tests/import_file_with_colon.ts.out b/cli/tests/import_file_with_colon.ts.out new file mode 100644 index 0000000000..f60bbf4b1b --- /dev/null +++ b/cli/tests/import_file_with_colon.ts.out @@ -0,0 +1 @@ +Hello from file_with_:_in_name.ts diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 89b5cc21e5..687ab53dc5 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2220,6 +2220,12 @@ itest!(compiler_js_error { exit_code: 1, }); +itest!(import_file_with_colon { + args: "run --quiet --reload import_file_with_colon.ts", + output: "import_file_with_colon.ts.out", + http_server: true, +}); + #[test] fn cafile_env_fetch() { use url::Url; diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index a6dc478729..7c754e02d1 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -354,6 +354,17 @@ pub async fn run_all_servers() { HeaderValue::from_static("application/javascript"), ); res + })) + .or(warp::path!("cli"/"tests"/"subdir"/"file_with_:_in_name.ts").map(|| { + let mut res = Response::new(Body::from( + "console.log('Hello from file_with_:_in_name.ts');", + )); + let h = res.headers_mut(); + h.insert( + "Content-type", + HeaderValue::from_static("application/typescript"), + ); + res })); let content_type_handler = warp::any()