Skip to content

Commit

Permalink
improve parsing of GitHub remotes URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jhspetersson committed Oct 2, 2024
1 parent 26b5621 commit 25ccd27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/connectors/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| {

impl RemoteConnector for GithubRemoteConnector {
fn supports_remote(&self, url: &str) -> Option<(String, String)> {
match Regex::new("https://github.com/([a-z0-9-]+)/([a-z0-9-]+)\\.?").unwrap().captures(url) {
Some(caps) if caps.len() == 3 => {
let user = caps.get(1)?.as_str().to_string();
let repo = caps.get(2)?.as_str().to_string();
match Regex::new("((https://)|(git@))github.com[/:](?P<user>[a-z0-9-]+)/(?P<repo>[a-z0-9-]+)(\\.git)?").unwrap().captures(url) {
Some(caps) if caps.len() >= 3 => {
let user = caps.name("user")?.as_str().to_string();
let repo = caps.name("repo")?.as_str().to_string();
Some((user, repo))
},
_ => None,
Expand Down

0 comments on commit 25ccd27

Please sign in to comment.