From fdbf61404d0106aab0a383eded709bc83f681b3e Mon Sep 17 00:00:00 2001 From: Rashil Gandhi Date: Tue, 22 Mar 2022 02:22:36 +0530 Subject: [PATCH] optimize --- lib/core.ps1 | 4 +--- lib/install.ps1 | 9 +++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index cc7606f015..094f93e9b7 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -1033,9 +1033,7 @@ function handle_special_urls($url) # Github.com if ($url -match 'github.com/(?[^/]+)/(?[^/]+)/releases/download/(?[^/]+)/(?[^/#]+)(?.*)' -and ($token = get_config 'checkver_token')) { - $headers = @{ - "Authorization" = "token $token" - } + $headers = @{ "Authorization" = "token $token" } $privateUrl = "https://api.github.com/repos/$($Matches.owner)/$($Matches.repo)" $assetUrl = "https://api.github.com/repos/$($Matches.owner)/$($Matches.repo)/releases/tags/$($Matches.tag)" diff --git a/lib/install.ps1 b/lib/install.ps1 index aad37b390d..aed16beecd 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -402,12 +402,9 @@ function dl($url, $to, $cookies, $progress) { $wreq.Headers.Add('Cookie', (cookie_header $cookies)) } - $privateHosts = get_config 'private_hosts' - if ($privateHosts) { - $privateHosts | Where-Object { $url -match $_.match } | ForEach-Object { - (ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object { - $wreq.Headers[$_.Key] = $_.Value - } + get_config 'private_hosts' | Where-Object { $url -match $_.match } | ForEach-Object { + (ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object { + $wreq.Headers[$_.Key] = $_.Value } } }