From 019b357ca8db17615becac955f7afc17153d2f22 Mon Sep 17 00:00:00 2001 From: Sebastian Turner Date: Sat, 17 Oct 2026 19:09:45 -0700 Subject: [PATCH] Classify GITHUB_HOST case insensitively Signed-off-by: Sebastian Turner --- pkg/utils/api.go | 6 ++++-- pkg/utils/api_test.go | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/utils/api.go b/pkg/utils/api.go index 4a8d14e4ef..7a008b6791 100644 --- a/pkg/utils/api.go +++ b/pkg/utils/api.go @@ -301,10 +301,12 @@ const ( ) func classifyHost(u *url.URL) HostType { + // Hostnames are case-insensitive, so "https://GitHub.com" is still github.com. + hostname := strings.ToLower(u.Hostname()) switch { - case u.Hostname() == "github.com" || strings.HasSuffix(u.Hostname(), ".github.com"): + case hostname == "github.com" || strings.HasSuffix(hostname, ".github.com"): return HostTypeDotcom - case u.Hostname() == "ghe.com" || strings.HasSuffix(u.Hostname(), ".ghe.com"): + case hostname == "ghe.com" || strings.HasSuffix(hostname, ".ghe.com"): return HostTypeGHEC default: return HostTypeGHES diff --git a/pkg/utils/api_test.go b/pkg/utils/api_test.go index baa1eb30ce..0ef753e35b 100644 --- a/pkg/utils/api_test.go +++ b/pkg/utils/api_test.go @@ -55,6 +55,16 @@ func TestParseAPIHost(t *testing.T) { input: "https://myghe.com", wantRestURL: "https://myghe.com/api/v3/", }, + { + name: "mixed case github.com hostname", + input: "https://GitHub.com", + wantRestURL: "https://api.github.com/", + }, + { + name: "mixed case ghe.com subdomain", + input: "https://Contoso.GHE.com", + wantRestURL: "https://api.Contoso.GHE.com/", + }, { name: "missing scheme", input: "github.com",