mirror of
https://github.com/openai/codex.git
synced 2026-09-09 15:58:47 +00:00
Normalize marketplace GitHub URLs with trailing slash
This commit is contained in:
@@ -308,6 +308,7 @@ fn non_empty_ref(ref_name: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
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!(
|
||||
|
||||
Reference in New Issue
Block a user