summaryrefslogtreecommitdiff
path: root/cli/permissions.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2020-02-23 06:45:02 -0800
committerGitHub <noreply@github.com>2020-02-23 09:45:02 -0500
commite9fff02e9681f3eb2edee9f94db66b140e179899 (patch)
treedebb7868de81f91e0f4e67a0bcf8cc592e9c8e2b /cli/permissions.rs
parentbf48f5fa5a15e01d6f8b7eb7c3e70f6ecc91fa23 (diff)
fetch: proper error for unsupported protocol (#4085)
Diffstat (limited to 'cli/permissions.rs')
-rw-r--r--cli/permissions.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/cli/permissions.rs b/cli/permissions.rs
index 868f0e009..950bec400 100644
--- a/cli/permissions.rs
+++ b/cli/permissions.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::deno_error::{other_error, permission_denied_msg};
+use crate::deno_error::{DenoError, ErrorKind};
use crate::flags::DenoFlags;
use ansi_term::Style;
#[cfg(not(test))]
@@ -193,8 +194,11 @@ impl DenoPermissions {
}
pub fn check_net_url(&self, url: &url::Url) -> Result<(), ErrBox> {
+ let host = url.host_str().ok_or_else(|| {
+ DenoError::new(ErrorKind::URIError, "missing host".to_owned())
+ })?;
self
- .get_state_net(&format!("{}", url.host().unwrap()), url.port())
+ .get_state_net(host, url.port())
.check(&format!("network access to \"{}\"", url), "--allow-net")
}