Skip to content

Commit 7b29c8e

Browse files
committed
Normalize hostname checking for tenancy or enterprise
This aligns the `cli/cli` behavior of IsTenancy and IsEnterprise with the counterparts here.
1 parent 6e9fb7c commit 7b29c8e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/auth/auth.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ func defaultHost(cfg *config.Config) (string, string) {
153153
const tenancyHost = "ghe.com"
154154

155155
func IsEnterprise(host string) bool {
156-
return host != github && host != localhost && !IsTenancy(host)
156+
normalizedHost := normalizeHostname(host)
157+
return normalizedHost != github && normalizedHost != localhost && !IsTenancy(normalizedHost)
157158
}
158159

159160
func IsTenancy(host string) bool {
160-
return strings.HasSuffix(host, "."+tenancyHost)
161+
normalizedHost := normalizeHostname(host)
162+
return strings.HasSuffix(normalizedHost, "."+tenancyHost)
161163
}
162164

163165
func normalizeHostname(host string) string {

0 commit comments

Comments
 (0)