Skip to content

Commit a154b16

Browse files
authored
Merge pull request #599 from ejball/ghe-raw-url
Fix GitHub Enterprise API URL for raw source code links.
2 parents 1a50e2c + e1820a4 commit a154b16

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/shared/GitHub/GitHubRestApi.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ private Uri GetApiRequestUri(Uri targetUri, string apiUrl)
212212
{
213213
// If we're here, it's GitHub Enterprise via a configured authority
214214
var baseUrl = targetUri.GetLeftPart(UriPartial.Authority);
215+
216+
// Check for 'raw.' in the hostname and remove it to get the correct GHE API URL
217+
baseUrl = Regex.Replace(baseUrl, @"^(https?://)raw\.", "$1", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
218+
215219
return new Uri(baseUrl + $"/api/v3/{apiUrl}");
216220
}
217221
}

0 commit comments

Comments
 (0)