summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/file_fetcher.rs2
-rw-r--r--cli/state.rs5
-rw-r--r--cli/tests/integration_tests.rs7
-rw-r--r--cli/tests/unsupported_dynamic_import_scheme.out5
4 files changed, 18 insertions, 1 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs
index 1a95fd547..c4e0e4fec 100644
--- a/cli/file_fetcher.rs
+++ b/cli/file_fetcher.rs
@@ -93,7 +93,7 @@ impl SourceFileFetcher {
Ok(file_fetcher)
}
- fn check_if_supported_scheme(url: &Url) -> Result<(), ErrBox> {
+ pub fn check_if_supported_scheme(url: &Url) -> Result<(), ErrBox> {
if !SUPPORTED_URL_SCHEMES.contains(&url.scheme()) {
return Err(
OpError::other(
diff --git a/cli/state.rs b/cli/state.rs
index acf418189..9fd719646 100644
--- a/cli/state.rs
+++ b/cli/state.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::compilers::TargetLib;
+use crate::file_fetcher::SourceFileFetcher;
use crate::global_state::GlobalState;
use crate::global_timer::GlobalTimer;
use crate::import_map::ImportMap;
@@ -474,6 +475,10 @@ impl State {
module_specifier: &ModuleSpecifier,
) -> Result<(), OpError> {
let u = module_specifier.as_url();
+ // TODO(bartlomieju): temporary fix to prevent hitting `unreachable`
+ // statement that is actually reachable...
+ SourceFileFetcher::check_if_supported_scheme(u)?;
+
match u.scheme() {
"http" | "https" => {
self.check_net_url(u)?;
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index ff3777626..b549dc6d0 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -1583,6 +1583,13 @@ itest!(run_v8_help {
output: "v8_help.out",
});
+itest!(unsupported_dynamic_import_scheme {
+ args: "eval import('xxx:')",
+ output: "unsupported_dynamic_import_scheme.out",
+ check_stderr: true,
+ exit_code: 1,
+});
+
itest!(wasm {
args: "run wasm.ts",
output: "wasm.ts.out",
diff --git a/cli/tests/unsupported_dynamic_import_scheme.out b/cli/tests/unsupported_dynamic_import_scheme.out
new file mode 100644
index 000000000..2a1a4e01f
--- /dev/null
+++ b/cli/tests/unsupported_dynamic_import_scheme.out
@@ -0,0 +1,5 @@
+error: Uncaught TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes: [
+ "http",
+ "https",
+ "file",
+]