mirror of
https://github.com/denoland/deno.git
synced 2025-01-09 07:39:15 -05:00
Fix resolve_module() when module_specifier is an absolute file path
This commit is contained in:
parent
3c2dbccdb9
commit
cc14df427f
1 changed files with 16 additions and 9 deletions
|
@ -76,15 +76,16 @@ fn resolve_module(
|
||||||
//let containing_file = src_file_to_url(containing_file);
|
//let containing_file = src_file_to_url(containing_file);
|
||||||
//let base_url = Url::parse(&containing_file)?;
|
//let base_url = Url::parse(&containing_file)?;
|
||||||
|
|
||||||
let j: Url = if containing_file.as_str().ends_with("/") {
|
let j: Url =
|
||||||
let base = Url::from_directory_path(&containing_file).unwrap();
|
if containing_file == "." || Path::new(module_specifier).is_absolute() {
|
||||||
base.join(module_specifier)?
|
Url::from_file_path(module_specifier).unwrap()
|
||||||
} else if containing_file == "." {
|
} else if containing_file.as_str().ends_with("/") {
|
||||||
Url::from_file_path(module_specifier).unwrap()
|
let base = Url::from_directory_path(&containing_file).unwrap();
|
||||||
} else {
|
base.join(module_specifier)?
|
||||||
let base = Url::from_file_path(&containing_file).unwrap();
|
} else {
|
||||||
base.join(module_specifier)?
|
let base = Url::from_file_path(&containing_file).unwrap();
|
||||||
};
|
base.join(module_specifier)?
|
||||||
|
};
|
||||||
|
|
||||||
let mut p = j.to_file_path()
|
let mut p = j.to_file_path()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -146,6 +147,12 @@ fn test_resolve_module() {
|
||||||
add_root!("/Users/rld/src/deno/hello.js"),
|
add_root!("/Users/rld/src/deno/hello.js"),
|
||||||
add_root!("/Users/rld/src/deno/hello.js"),
|
add_root!("/Users/rld/src/deno/hello.js"),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
add_root!("/this/module/got/imported.js"),
|
||||||
|
add_root!("/that/module/did/it.js"),
|
||||||
|
add_root!("/this/module/got/imported.js"),
|
||||||
|
add_root!("/this/module/got/imported.js"),
|
||||||
|
),
|
||||||
/*
|
/*
|
||||||
(
|
(
|
||||||
"http://localhost:4545/testdata/subdir/print_hello.ts",
|
"http://localhost:4545/testdata/subdir/print_hello.ts",
|
||||||
|
|
Loading…
Reference in a new issue