Skip to content

Commit a1e6789

Browse files
committed
Improve Get-PhalconReleaseAssetUrl
1 parent 9114b00 commit a1e6789

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/scripts/extensions/phalcon.ps1

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ Function Get-PhalconReleaseAssetUrl() {
88
)
99
$domain = 'https://api.github.com/repos'
1010
$releases = 'phalcon/cphalcon/releases'
11-
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
12-
$match = $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
13-
if($NULL -eq $match) {
14-
$match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
15-
}
16-
if($NULL -eq $match) {
11+
if($extension_version -match '[3-4]') {
12+
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
13+
try {
14+
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
15+
} catch {
16+
$match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
17+
}
18+
} else {
1719
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
18-
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
19-
}
20-
if($NULL -eq $match) {
21-
$match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
20+
try {
21+
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
22+
} catch {
23+
$match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
24+
}
2225
}
2326
if($NULL -ne $match) {
2427
return "$github/$releases/download/v$Semver/$($match.Matches[0].Groups[1].Value)"

0 commit comments

Comments
 (0)