Skip to content

Commit 54b2de2

Browse files
committed
Assume that github.localhost is available through http: and not https:
1 parent e43777e commit 54b2de2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

internal/ghinstance/host.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,28 @@ func GraphQLEndpoint(hostname string) string {
5555
if IsEnterprise(hostname) {
5656
return fmt.Sprintf("https://%s/api/graphql", hostname)
5757
}
58+
if strings.EqualFold(hostname, localhost) {
59+
return fmt.Sprintf("http://api.%s/graphql", hostname)
60+
}
5861
return fmt.Sprintf("https://api.%s/graphql", hostname)
5962
}
6063

6164
func RESTPrefix(hostname string) string {
6265
if IsEnterprise(hostname) {
6366
return fmt.Sprintf("https://%s/api/v3/", hostname)
6467
}
68+
if strings.EqualFold(hostname, localhost) {
69+
return fmt.Sprintf("http://api.%s/", hostname)
70+
}
6571
return fmt.Sprintf("https://api.%s/", hostname)
6672
}
6773

6874
func GistPrefix(hostname string) string {
6975
if IsEnterprise(hostname) {
7076
return fmt.Sprintf("https://%s/gist/", hostname)
7177
}
78+
if strings.EqualFold(hostname, localhost) {
79+
return fmt.Sprintf("http://%s/gist/", hostname)
80+
}
7281
return fmt.Sprintf("https://gist.%s/", hostname)
7382
}

internal/ghinstance/host_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TestGraphQLEndpoint(t *testing.T) {
147147
},
148148
{
149149
host: "github.localhost",
150-
want: "https://api.github.localhost/graphql",
150+
want: "http://api.github.localhost/graphql",
151151
},
152152
{
153153
host: "ghe.io",
@@ -174,7 +174,7 @@ func TestRESTPrefix(t *testing.T) {
174174
},
175175
{
176176
host: "github.localhost",
177-
want: "https://api.github.localhost/",
177+
want: "http://api.github.localhost/",
178178
},
179179
{
180180
host: "ghe.io",

0 commit comments

Comments
 (0)