diff --git a/lib/core.ps1 b/lib/core.ps1 index a61f793072..7869ef8ab1 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -1243,6 +1243,19 @@ function handle_special_urls($url) } } + # Github enterprise + get_config PRIVATE_HOSTS | Where-Object { $_ -ne $null -and $url -match $_.match } | ForEach-Object { + if ($url -match '(?[^/]+)/(?[^/]+)/(?[^/]+)/releases/download/(?[^/]+)/(?[^/#]+)(?.*)') { + $headers = (ConvertFrom-StringData -StringData $_.Headers) + $privateUrl = "https://$($Matches.host)/api/v3/repos/$($Matches.owner)/$($Matches.repo)" + $assetUrl = "https://$($Matches.host)/api/v3/repos/$($Matches.owner)/$($Matches.repo)/releases/tags/$($Matches.tag)" + + if ((Invoke-RestMethod -Uri $privateUrl -Headers $headers).Private) { + $url = ((Invoke-RestMethod -Uri $assetUrl -Headers $headers).Assets | Where-Object -Property Name -EQ -Value $Matches.file).Url, $Matches.filename -join '' + } + } + } + return $url } diff --git a/lib/install.ps1 b/lib/install.ps1 index 22b76423ca..a82f0614ba 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -376,6 +376,9 @@ function Invoke-Download ($url, $to, $cookies, $progress) { (ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object { $wreq.Headers[$_.Key] = $_.Value } + if ($null -ne $_.Accept) { + $wreq.Accept = $_.Accept + } } }