Skip to content

Commit

Permalink
fix: respect port in GitHub URLs
Browse files Browse the repository at this point in the history
Previously, when reconstructing the domain, we dropped the port
completely.
  • Loading branch information
mistydemeo committed Oct 31, 2024
1 parent d583841 commit 112335c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion axoupdater/src/release/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ fn github_api(app_name: &str) -> AxoupdateResult<String> {
url: value,
});
};
Ok(format!("{}://api.{}", parsed.scheme(), domain))
let port = parsed.port().map(|p| format!(":{p}")).unwrap_or_default();
Ok(format!("{}://api.{}{}", parsed.scheme(), domain, port))
} else {
Ok("https://api.github.com".to_string())
}
Expand Down Expand Up @@ -376,6 +377,16 @@ mod test {
assert!(result.is_err());
}

#[test]
#[serial] // modifying the global state environment variables
fn test_github_api_overwrite_port() {
env::set_var("DIST_INSTALLER_GITHUB_BASE_URL", "https://magic.com:8000");
let result = github_api("dist").unwrap();
env::remove_var("DIST_INSTALLER_GITHUB_BASE_URL");

assert_eq!(result, "https://api.magic.com:8000");
}

#[test]
#[serial] // modifying the global state environment variables
fn test_github_api_overwrite_bad_value() {
Expand Down

0 comments on commit 112335c

Please sign in to comment.