aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-08-05 01:14:19 +0200
committerTeddy Wing2020-08-05 01:14:19 +0200
commita3dcf7fa8c14b809174edd725ef5d46557803521 (patch)
tree9b2f143ef3c8f4772bcc2757b431b22c075bed20
parent451065229d47288d0f4b0b055dc459e7b7984d86 (diff)
downloadgit-suggestion-a3dcf7fa8c14b809174edd725ef5d46557803521.tar.bz2
OwnerRepo: Remove ".git" suffix from HTTPS URLs
I hadn't tested with HTTPS remote URLs, so assumed the code I copied from `github_suggestion::url` would work. It worked for suggestion comment URLs, but it doesn't work for remote URLs because the latter end in ".git". Remove this suffix to fix the bug.
-rw-r--r--src/owner_repo.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/owner_repo.rs b/src/owner_repo.rs
index ea5a510..273ef6f 100644
--- a/src/owner_repo.rs
+++ b/src/owner_repo.rs
@@ -76,9 +76,13 @@ impl FromStr for OwnerRepo {
return Err(OwnerRepoError::NoOwnerRepo);
}
+ let repo = path[1]
+ .strip_suffix(".git")
+ .unwrap_or(path[1]);
+
Ok(OwnerRepo {
owner: path[0].to_owned(),
- repo: path[1].to_owned(),
+ repo: repo.to_owned(),
})
}
}