Fix panicking when passed a file:// URL

Closes #347
This commit is contained in:
Sean McArthur
2018-09-18 12:42:49 -07:00
parent 68d012e954
commit 610cdd266c
5 changed files with 50 additions and 20 deletions

View File

@@ -49,7 +49,7 @@ impl Proxy {
/// # fn main() {}
/// ```
pub fn http<U: IntoUrl>(url: U) -> ::Result<Proxy> {
let uri = ::into_url::to_uri(&try_!(url.into_url()));
let uri = ::into_url::to_uri(&url.into_url()?);
Ok(Proxy::new(Intercept::Http(uri)))
}
@@ -68,7 +68,7 @@ impl Proxy {
/// # fn main() {}
/// ```
pub fn https<U: IntoUrl>(url: U) -> ::Result<Proxy> {
let uri = ::into_url::to_uri(&try_!(url.into_url()));
let uri = ::into_url::to_uri(&url.into_url()?);
Ok(Proxy::new(Intercept::Https(uri)))
}
@@ -87,7 +87,7 @@ impl Proxy {
/// # fn main() {}
/// ```
pub fn all<U: IntoUrl>(url: U) -> ::Result<Proxy> {
let uri = ::into_url::to_uri(&try_!(url.into_url()));
let uri = ::into_url::to_uri(&url.into_url()?);
Ok(Proxy::new(Intercept::All(uri)))
}