Skip to content
Merged
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
21 changes: 20 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub use error::GitUrlParseError;

use core::str;
use std::fmt;
use url::Url;

use getset::{CloneGetters, CopyGetters, Setters};
#[cfg(feature = "log")]
Expand Down Expand Up @@ -140,6 +141,24 @@ impl<'url> GitUrl<'url> {
}
}

#[cfg(feature = "url")]
impl<'url> TryFrom<&GitUrl<'url>> for Url {
type Error = url::ParseError;
fn try_from(value: &GitUrl) -> Result<Self, Self::Error> {
// Since we don't fully implement any spec, we'll rely on the url crate
Url::parse(&value.url_compat_display())
}
}

#[cfg(feature = "url")]
impl<'url> TryFrom<GitUrl<'url>> for Url {
type Error = url::ParseError;
fn try_from(value: GitUrl) -> Result<Self, Self::Error> {
// Since we don't fully implement any spec, we'll rely on the url crate
Url::parse(&value.url_compat_display())
}
}

impl<'url> GitUrl<'url> {
/// Returns `GitUrl` after removing all user info values
pub fn trim_auth(&self) -> GitUrl {
Expand Down Expand Up @@ -325,7 +344,7 @@ impl<'url> GitUrl<'url> {
#[cfg(feature = "url")]
{
// Since we don't fully implement any spec, we'll rely on the url crate
let _u = url::Url::parse(&self.url_compat_display())?;
let _u: Url = self.try_into()?;
}

Ok(())
Expand Down
Loading