From fcb857d75dde7a0b455a3b6873f4884a006b58e7 Mon Sep 17 00:00:00 2001 From: amru14-sys Date: Sat, 28 Feb 2026 14:11:54 +0530 Subject: [PATCH] add host agnostic authenticated URL formation --- src/ci/github.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ci/github.rs b/src/ci/github.rs index d93917750..f64eda309 100644 --- a/src/ci/github.rs +++ b/src/ci/github.rs @@ -68,9 +68,11 @@ pub fn get_github_ci_context() -> Result, GitAiError> { // Authenticate the clone URL with GITHUB_TOKEN if available let authenticated_url = if let Ok(token) = std::env::var("GITHUB_TOKEN") { // Replace https://github.com/ with https://x-access-token:TOKEN@github.com/ - clone_url.replace( - "https://github.com/", - &format!("https://x-access-token:{}@github.com/", token), + // Supports both public and enterprise github instances. + format!( + "https://x-access-token:{}@{}", + token, + clone_url.strip_prefix("https://").unwrap_or(&clone_url) ) } else { clone_url