Skip to content

Commit

Permalink
Select first match from curl output
Browse files Browse the repository at this point in the history
  • Loading branch information
reuteras committed Jan 18, 2024
1 parent 69dce4c commit f259326
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions resources/download/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ function Get-FileFromUri {
}

if ($Uri -like "*marketplace.visualstudio.com*") {
# Download from Visual Studio Marketplace
Invoke-WebRequest -uri $Uri -outfile $TmpFilePath -RetryIntervalSec 20 -MaximumRetryCount 3
} else {
$CMD = "curl.exe"
Expand Down Expand Up @@ -358,12 +357,12 @@ function Get-DownloadUrlFromPage {
try {
if ($Url -contains "github.com") {
if ($GH_USER -eq "" -or $GH_PASS -eq "") {
$downloadUrl = curl.exe --silent -L "$Url" | Select-String -Pattern "$RegEx" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value
$downloadUrl = curl.exe --silent -L "$Url" | Select-String -Pattern "$RegEx" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value | Select-Object -First 1
} else {
$downloadUrl = curl.exe --silent -L -u "${GH_USER}:${GH_PASS}" "$Url" | Select-String -Pattern "$RegEx" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value
$downloadUrl = curl.exe --silent -L -u "${GH_USER}:${GH_PASS}" "$Url" | Select-String -Pattern "$RegEx" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value | Select-Object -First 1
}
} else {
$downloadUrl = curl.exe --silent -L "$Url" | Select-String -Pattern "$RegEx" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value
$downloadUrl = curl.exe --silent -L "$Url" | Select-String -Pattern "$RegEx" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value | Select-Object -First 1
}
}
catch {
Expand Down

0 comments on commit f259326

Please sign in to comment.