Skip to content

Commit f90f446

Browse files
committed
turn apiHost into an immutable function
1 parent a98ff35 commit f90f446

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

graphql/enterprise/index.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,16 @@ <h3>Create a <a href="https://help.github.com/articles/creating-a-personal-acces
173173

174174
const hostnames = location.hostname.split('.')
175175

176-
if (hostnames[0] === "pages") {
177-
// subdomain isolation enabled, so remove the first part of the URL
178-
hostnames.shift()
179-
const apiHost = location.protocol + '//' + hostnames.join('.')
180-
} else {
181-
// no subdomain isolation
182-
const apiHost = location.protocol + '//' + location.hostname
183-
}
176+
const apiHost = function () {
177+
if (hostnames[0] === "pages") {
178+
// subdomain isolation enabled, so remove the first part of the URL
179+
hostnames.shift()
180+
return location.protocol + '//' + hostnames.join('.')
181+
} else {
182+
// no subdomain isolation
183+
return location.protocol + '//' + location.hostname
184+
}
185+
}()
184186

185187
return fetch(apiHost + '/api/graphql', {
186188
method: 'post',

0 commit comments

Comments
 (0)