diff --git a/codex-rs/cli/src/marketplace_cmd.rs b/codex-rs/cli/src/marketplace_cmd.rs index e26f80638d..f5df805e4b 100644 --- a/codex-rs/cli/src/marketplace_cmd.rs +++ b/codex-rs/cli/src/marketplace_cmd.rs @@ -308,6 +308,7 @@ fn non_empty_ref(ref_name: &str) -> Option { } fn normalize_git_url(url: &str) -> String { + let url = url.trim_end_matches('/'); if url.starts_with("https://github.com/") && !url.ends_with(".git") { format!("{url}.git") } else { @@ -520,6 +521,21 @@ mod tests { ); } + #[test] + fn github_url_with_trailing_slash_normalizes_without_extra_path_segment() { + assert_eq!( + parse_marketplace_source( + "https://github.com/owner/repo/", + /* explicit_ref */ None + ) + .unwrap(), + MarketplaceSource::Git { + url: "https://github.com/owner/repo.git".to_string(), + ref_name: None, + } + ); + } + #[test] fn non_github_https_source_parses_as_git_url() { assert_eq!(