Skip to content

Commit 969d582

Browse files
committed
Add doctest for parse_to_url
1 parent 0ae243b commit 969d582

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/types/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,23 @@ impl GitUrl {
274274
}
275275

276276
/// Normalize input into form that can be used by [`Url::parse`](https://docs.rs/url/latest/url/struct.Url.html#method.parse)
277+
///
278+
/// ```
279+
/// use git_url_parse::GitUrl;
280+
/// #[cfg(feature = "url")]
281+
/// use url::Url;
282+
///
283+
/// fn main() -> Result<(), git_url_parse::GitUrlParseError> {
284+
/// let ssh_url = GitUrl::parse_to_url("[email protected]:tjtelan/git-url-parse-rs.git")?;
285+
///
286+
/// assert_eq!(ssh_url.scheme(), "ssh");
287+
/// assert_eq!(ssh_url.username(), "git");
288+
/// assert_eq!(ssh_url.host_str(), Some("github.com"));
289+
/// assert_eq!(ssh_url.path(), "/tjtelan/git-url-parse-rs.git");
290+
/// Ok(())
291+
/// }
292+
/// ```
293+
///
277294
#[cfg(feature = "url")]
278295
pub fn parse_to_url(input: &str) -> Result<Url, GitUrlParseError> {
279296
let git_url = Self::parse_to_git_url(input)?;

0 commit comments

Comments
 (0)