diff options
author | Mark Gibson <mgibson@adaptavist.com> | 2022-10-13 10:01:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 11:01:11 +0200 |
commit | fda24b54e955c341c37ee29fbe59d9f7580e25e1 (patch) | |
tree | 0ae77a9f6339e97e1998c2680d3a3ae566643e50 | |
parent | 06ccb6d41e1b89bff587a6dbac698c912d1c1090 (diff) |
fix(cli): allow importMap to be an absolute URL within the deno config file (#16234)
-rw-r--r-- | cli/args/mod.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 1e0c72b1c..e46313858 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -420,6 +420,10 @@ fn resolve_import_map_specifier( // and with config files, we support both local and remote config files, // so we have treat them differently. if let Some(import_map_path) = config_file.to_import_map_path() { + // if the import map is an absolute URL, use it as is + if let Ok(specifier) = deno_core::resolve_url(&import_map_path) { + return Ok(Some(specifier)); + } let specifier = // with local config files, it might be common to specify an import // map like `"importMap": "import-map.json"`, which is resolvable if @@ -472,6 +476,25 @@ mod test { } #[test] + fn resolve_import_map_remote_config_file_local() { + let config_text = r#"{ + "importMap": "https://example.com/import_map.json" + }"#; + let config_specifier = + ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap(); + let config_file = ConfigFile::new(config_text, &config_specifier).unwrap(); + let actual = resolve_import_map_specifier(None, Some(&config_file)); + assert!(actual.is_ok()); + let actual = actual.unwrap(); + assert_eq!( + actual, + Some( + ModuleSpecifier::parse("https://example.com/import_map.json").unwrap() + ) + ); + } + + #[test] fn resolve_import_map_config_file_remote() { let config_text = r#"{ "importMap": "./import_map.json" |