fix(deno install): support file: scheme URLs (#10562)

This commit is contained in:
Satya Rohith 2021-05-19 17:10:23 +05:30 committed by Bert Belder
parent 44cd0b1ef6
commit 7a751b8135
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
2 changed files with 54 additions and 39 deletions

View file

@ -11,7 +11,6 @@ use crate::module_graph;
use crate::program_state::ProgramState;
use crate::tokio_util;
use crate::tools::coverage::CoverageCollector;
use crate::tools::installer::is_remote_url;
use deno_core::error::AnyError;
use deno_core::futures::future;
use deno_core::futures::stream;
@ -226,6 +225,11 @@ pub(crate) fn is_supported(p: &Path) -> bool {
}
}
pub fn is_remote_url(module_url: &str) -> bool {
let lower = module_url.to_lowercase();
lower.starts_with("http://") || lower.starts_with("https://")
}
pub fn collect_test_module_specifiers<P>(
include: Vec<String>,
root_path: &Path,
@ -642,4 +646,14 @@ mod tests {
.collect();
assert_eq!(matched_urls, expected);
}
#[test]
fn test_is_remote_url() {
assert!(is_remote_url("https://deno.land/std/http/file_server.ts"));
assert!(is_remote_url("http://deno.land/std/http/file_server.ts"));
assert!(is_remote_url("HTTP://deno.land/std/http/file_server.ts"));
assert!(is_remote_url("HTTp://deno.land/std/http/file_server.ts"));
assert!(!is_remote_url("file:///dev/deno_std/http/file_server.ts"));
assert!(!is_remote_url("./dev/deno_std/http/file_server.ts"));
}
}