From f25932691e426731a20751a97889ff954669f5f6 Mon Sep 17 00:00:00 2001 From: Coding for fun Date: Thu, 18 Jan 2024 09:30:11 +0100 Subject: [PATCH] Select first match from curl output --- resources/download/common.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/resources/download/common.ps1 b/resources/download/common.ps1 index 15db0d5..331a7de 100644 --- a/resources/download/common.ps1 +++ b/resources/download/common.ps1 @@ -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" @@ -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 {