Skip to content

Commit f7b956d

Browse files
v2kiranHowardWolosky
authored andcommitted
Fix hostname support for Enterprise installations of GitHub (#118)
Per the [documentation](https://developer.github.com/enterprise/2.16/v3/#current-version), enterprise installations support a base URL of `http(s)://[hostname]/api/v3` in addition to the existing support of `http(s)://api.[hostname]/`. This PR updates the module to _always_ use the `http(s)://[hostname]/api/v3` syntax when `[hostname]` is _not_ `github.com`. Fixes #117
1 parent f0bd316 commit f7b956d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

GitHubCore.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,14 @@ function Invoke-GHRestMethod
153153

154154
$hostName = $(Get-GitHubConfiguration -Name "ApiHostName")
155155

156-
$url = "https://api.$hostName/$UriFragment"
156+
if ($hostName -eq 'github.com')
157+
{
158+
$url = "https://api.$hostName/$UriFragment"
159+
}
160+
else
161+
{
162+
$url = "https://$hostName/api/v3/$UriFragment"
163+
}
157164

158165
# It's possible that we are directly calling the "nextLink" from a previous command which
159166
# provides the full URI. If that's the case, we'll just use exactly what was provided to us.
@@ -966,4 +973,3 @@ function Get-MediaAcceptHeader
966973

967974
return ($acceptHeaders -join ',')
968975
}
969-

0 commit comments

Comments
 (0)