Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ mod tests {
async fn execute_request_rejects_invalid_urls() {
let url_str = "hxxps://www.rust-lang.org/";
let url = url::Url::parse(url_str).unwrap();
let result = crate::get(url.clone()).await;
let result = crate::get(&url).await;

assert!(result.is_err());
let err = result.err().unwrap();
Expand All @@ -3123,7 +3123,7 @@ mod tests {
async fn execute_request_rejects_invalid_hostname() {
let url_str = "https://{{hostname}}/";
let url = url::Url::parse(url_str).unwrap();
let result = crate::get(url.clone()).await;
let result = crate::get(&url).await;

assert!(result.is_err());
let err = result.err().unwrap();
Expand Down
11 changes: 11 additions & 0 deletions src/into_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use url::Url;
pub trait IntoUrl: IntoUrlSealed {}

impl IntoUrl for Url {}
impl<'a> IntoUrl for &'a Url {}
impl IntoUrl for String {}
impl<'a> IntoUrl for &'a str {}
impl<'a> IntoUrl for &'a String {}
Expand Down Expand Up @@ -43,6 +44,16 @@ impl IntoUrlSealed for Url {
}
}

impl<'a> IntoUrlSealed for &'a Url {
fn into_url(self) -> crate::Result<Url> {
self.clone().into_url()
}

fn as_str(&self) -> &str {
self.as_ref()
}
}

impl<'a> IntoUrlSealed for &'a str {
fn into_url(self) -> crate::Result<Url> {
Url::parse(self).map_err(crate::error::builder)?.into_url()
Expand Down