Skip to content

Commit

Permalink
Normalize hostname checking for tenancy or enterprise
Browse files Browse the repository at this point in the history
This aligns the `cli/cli` behavior of IsTenancy and IsEnterprise with the counterparts here.
  • Loading branch information
andyfeller committed Mar 18, 2024
1 parent 6e9fb7c commit 7b29c8e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/auth/auth.go
Expand Up @@ -153,11 +153,13 @@ func defaultHost(cfg *config.Config) (string, string) {
const tenancyHost = "ghe.com"

func IsEnterprise(host string) bool {
return host != github && host != localhost && !IsTenancy(host)
normalizedHost := normalizeHostname(host)
return normalizedHost != github && normalizedHost != localhost && !IsTenancy(normalizedHost)
}

func IsTenancy(host string) bool {
return strings.HasSuffix(host, "."+tenancyHost)
normalizedHost := normalizeHostname(host)
return strings.HasSuffix(normalizedHost, "."+tenancyHost)
}

func normalizeHostname(host string) string {
Expand Down

0 comments on commit 7b29c8e

Please sign in to comment.