Normalize marketplace GitHub URLs with trailing slash

This commit is contained in:
xli-oai
2026-04-10 12:55:09 -07:00
parent 238f4b1214
commit 674015acdf

View File

@@ -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!(