Crates.io | git-url-parse |
lib.rs | git-url-parse |
version | 0.4.5 |
source | src |
created_at | 2020-01-22 06:55:30.492927 |
updated_at | 2024-09-06 08:39:55.149327 |
description | A parser for git repo urls based on url crate |
homepage | |
repository | https://github.com/tjtelan/git-url-parse-rs |
max_upload_size | |
id | 200968 |
size | 87,774 |
Supports common protocols as specified by the Pro Git book
See: 4.1 Git on the Server - The Protocols
Supports parsing SSH/HTTPS repo urls for:
See tests/parse.rs for expected output for a variety of inputs.
URLs that use the ssh://
protocol (implicitly or explicitly) undergo a small normalization process in order to be parsed.
Internally uses Url::parse()
from the Url crate after normalization.
$ RUST_LOG=git_url_parse cargo run --example multi
$ RUST_LOG=git_url_parse cargo run --example trim_auth
$ cargo run --example readme
use git_url_parse::GitUrl;
fn main() {
println!("SSH: {:#?}", GitUrl::parse("git@github.com:tjtelan/git-url-parse-rs.git"));
println!("HTTPS: {:#?}", GitUrl::parse("https://github.com/tjtelan/git-url-parse-rs"));
}
SSH: Ok(
GitUrl {
host: Some(
"github.com",
),
name: "git-url-parse-rs",
owner: Some(
"tjtelan",
),
organization: None,
fullname: "tjtelan/git-url-parse-rs",
scheme: Ssh,
user: Some(
"git",
),
token: None,
port: None,
path: "tjtelan/git-url-parse-rs.git",
git_suffix: true,
scheme_prefix: false,
},
)
HTTPS: Ok(
GitUrl {
host: Some(
"github.com",
),
name: "git-url-parse-rs",
owner: Some(
"tjtelan",
),
organization: None,
fullname: "tjtelan/git-url-parse-rs",
scheme: Https,
user: None,
token: None,
port: None,
path: "/tjtelan/git-url-parse-rs",
git_suffix: false,
scheme_prefix: true,
},
)