Skip to content
Permalink
Browse files

fix absolute path resolution from remote (denoland#2109)

  • Loading branch information...
kt3k authored and ry committed Apr 13, 2019
1 parent 591b5e4 commit 635ad2a18ecd26690e611f54062ae899fe307f96
Showing with 23 additions and 1 deletion.
  1. +23 −1 cli/deno_dir.rs
@@ -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();

0 comments on commit 635ad2a

Please sign in to comment.
You can’t perform that action at this time.