mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
fix(vendor): properly handle bare specifiers that start with http (#16885)
This commit is contained in:
parent
0a82f3c0e9
commit
fafb3eebaf
2 changed files with 37 additions and 1 deletions
35
cli/tools/vendor/build.rs
vendored
35
cli/tools/vendor/build.rs
vendored
|
@ -1064,6 +1064,41 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn existing_import_map_http_key() {
|
||||
let mut builder = VendorTestBuilder::with_default_setup();
|
||||
let mut original_import_map = builder.new_import_map("/import_map.json");
|
||||
original_import_map
|
||||
.imports_mut()
|
||||
.append(
|
||||
"http/".to_string(),
|
||||
"https://deno.land/std/http/".to_string(),
|
||||
)
|
||||
.unwrap();
|
||||
let output = builder
|
||||
.with_loader(|loader| {
|
||||
loader.add("/mod.ts", "import 'http/mod.ts';");
|
||||
loader.add("https://deno.land/std/http/mod.ts", "console.log(5);");
|
||||
})
|
||||
.set_original_import_map(original_import_map.clone())
|
||||
.build()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
output.import_map,
|
||||
Some(json!({
|
||||
"imports": {
|
||||
"http/mod.ts": "./deno.land/std/http/mod.ts",
|
||||
"https://deno.land/": "./deno.land/",
|
||||
}
|
||||
}))
|
||||
);
|
||||
assert_eq!(
|
||||
output.files,
|
||||
to_file_vec(&[("/vendor/deno.land/std/http/mod.ts", "console.log(5);")]),
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn vendor_file_fails_loading_dynamic_import() {
|
||||
let mut builder = VendorTestBuilder::with_default_setup();
|
||||
|
|
3
cli/tools/vendor/specifiers.rs
vendored
3
cli/tools/vendor/specifiers.rs
vendored
|
@ -69,7 +69,8 @@ pub fn is_remote_specifier(specifier: &ModuleSpecifier) -> bool {
|
|||
}
|
||||
|
||||
pub fn is_remote_specifier_text(text: &str) -> bool {
|
||||
text.trim_start().to_lowercase().starts_with("http")
|
||||
let text = text.trim_start().to_lowercase();
|
||||
text.starts_with("http:") || text.starts_with("https:")
|
||||
}
|
||||
|
||||
pub fn sanitize_filepath(text: &str) -> String {
|
||||
|
|
Loading…
Reference in a new issue