1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 21:50:00 -05:00

fix absolute path resolution from remote (#2109)

This commit is contained in:
Yoshiya Hinosawa 2019-04-14 02:27:27 +09:00 committed by Ryan Dahl
parent 591b5e4a7d
commit 635ad2a18e

View file

@ -284,7 +284,9 @@ impl DenoDir {
referrer = referrer_path.to_str().unwrap().to_string() + "/";
}
let j = if is_remote(&specifier) || Path::new(&specifier).is_absolute() {
let j = if is_remote(&specifier)
|| (Path::new(&specifier).is_absolute() && !is_remote(&referrer))
{
parse_local_or_remote(&specifier)?
} else if referrer.ends_with('/') {
let r = Url::from_directory_path(&referrer);
@ -1674,6 +1676,26 @@ mod tests {
assert_eq!(filename, expected_filename);
}
#[test]
fn test_resolve_module_8() {
let (_temp_dir, deno_dir) = test_setup();
let specifier = "/util";
let referrer_ =
deno_dir.deps_https.join("unpkg.com/liltest@0.0.5/index.ts");
let referrer = referrer_.to_str().unwrap();
let expected_module_name = "https://unpkg.com/util";
let expected_filename = deno_fs::normalize_path(
deno_dir.deps_https.join("unpkg.com/util").as_ref(),
);
let (module_name, filename) =
deno_dir.resolve_module(specifier, referrer).unwrap();
assert_eq!(module_name, expected_module_name);
assert_eq!(filename, expected_filename);
}
#[test]
fn test_resolve_module_referrer_dot() {
let (_temp_dir, deno_dir) = test_setup();