Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git_hosting_providers: Support GitHub remote URLs that start with a slash (#34134)

Zachary Hamm66acc2698aa3
diff --git a/crates/git_hosting_providers/src/providers/github.rs b/crates/git_hosting_providers/src/providers/github.rs
index 649b2f30aee..30f8d058a7c 100644
--- a/crates/git_hosting_providers/src/providers/github.rs
+++ b/crates/git_hosting_providers/src/providers/github.rs
@@ -159,7 +159,11 @@ impl GitHostingProvider for Github {
}
let mut path_segments = url.path_segments()?;
- let owner = path_segments.next()?;
+ let mut owner = path_segments.next()?;
+ if owner.is_empty() {
+ owner = path_segments.next()?;
+ }
+
let repo = path_segments.next()?.trim_end_matches(".git");
Some(ParsedGitRemote {
@@ -244,6 +248,22 @@ mod tests {
use super::*;
+ #[test]
+ fn test_remote_url_with_root_slash() {
+ let remote_url = "[email protected]:/zed-industries/zed";
+ let parsed_remote = Github::public_instance()
+ .parse_remote_url(remote_url)
+ .unwrap();
+
+ assert_eq!(
+ parsed_remote,
+ ParsedGitRemote {
+ owner: "zed-industries".into(),
+ repo: "zed".into(),
+ }
+ );
+ }
+
#[test]
fn test_invalid_self_hosted_remote_url() {
let remote_url = "[email protected]:zed-industries/zed.git";