@@ -5,7 +5,7 @@ function Get-mySQLConnectorNET {
55 Twitter: @BornToBeRoot
66 #>
77 [OutputType ([System.Management.Automation.PSObject ])]
8- [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSUseSingularNouns" , " " , Justification= " Product name is a plural" )]
8+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSUseSingularNouns" , " " , Justification = " Product name is a plural" )]
99 [CmdletBinding (SupportsShouldProcess = $False )]
1010 param (
1111 [Parameter (Mandatory = $False , Position = 0 )]
@@ -14,24 +14,30 @@ function Get-mySQLConnectorNET {
1414 $res = (Get-FunctionResource - AppName (" $ ( $MyInvocation.MyCommand ) " .Split(" -" ))[1 ])
1515 )
1616
17- # Pass the repo releases API URL and return a formatted object
18- $params = @ {
19- Uri = $res.Get.Update.Uri
20- MatchVersion = $res.Get.Update.MatchVersion
21- Filter = $res.Get.Update.MatchFileTypes
22- ReturnVersionOnly = $True
23- }
24- $object = Get-GitHubRepoRelease @params
17+ # Get latest repo tag
18+ $Tags = Get-GitHubRepoTag - Uri $res.Get.Update.Uri
19+
20+ $Version = ($Tags | Sort-Object - Property @ { Expression = { [System.Version ]$_.Tag }; Descending = $true } | Select-Object - First 1 ).Tag
2521
2622 # Build the output object
27- if ($Null -ne $object ) {
23+ if ($Null -ne $Version ) {
2824 foreach ($Architecture in $res.Get.Download.Uri.GetEnumerator ()) {
29- $Uri = $res.Get.Download.Uri [$Architecture.Key ] -replace $res.Get.Download.ReplaceVersionShort , (($object.Version -split ' \.' )[0 , 1 ] -join ' .' ) -replace $res.Get.Download.ReplaceVersion , $object.Version
25+
26+ # https://dev.mysql.com/get/Downloads/Connector-ODBC/9.1/mysql-connector-odbc-9.1.0-winx64.msi
27+ # redirect to
28+ # https://cdn.mysql.com//Downloads/Connector-ODBC/9.1/mysql-connector-odbc-9.1.0-winx64.msi
29+ #
30+ # The sub path is only major.minor
31+ # The version ist major.minor.patch, while the tag can have also have major.minor.patch.build
32+ $Uri = $res.Get.Download.Uri [$Architecture.Key ] -replace $res.Get.Download.ReplaceVersionShort , (($Version -split ' \.' )[0 , 1 ] -join ' .' ) -replace $res.Get.Download.ReplaceVersion , (($Version -split ' \.' )[0 .. 2 ] -join ' .' )
33+
34+ $CdnUri = (Invoke-WebRequest $Uri - MaximumRedirection 0 - SkipHttpErrorCheck - ErrorAction:SilentlyContinue).Headers.Location[0 ]
35+
3036 $PSObject = [PSCustomObject ] @ {
31- Version = $object . Version
37+ Version = $Version
3238 Type = Get-FileType - File $Uri
3339 Architecture = $Architecture.Name
34- URI = $Uri
40+ URI = $CdnUri
3541 }
3642 Write-Output - InputObject $PSObject
3743 }
0 commit comments