Skip to content

Commit

Permalink
fix release fetching, same fix as tfswitch
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanealami authored and jb-abbadie committed May 10, 2022
1 parent 7691a50 commit e87de16
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/list_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ func GetTFList(mirrorURL string, preRelease bool) ([]string, error) {
var semver string
if preRelease {
// Getting versions from body; should return match /X.X.X-@/ where X is a number,@ is a word character between a-z or A-Z
semver = `\/(\d+\.\d+\.\d+)(-[a-zA-z]+\d*)?\/`
semver = `\/(\d+\.\d+\.\d+)(-[a-zA-z]+\d*)?\"`
} else if !preRelease {
// Getting versions from body; should return match /X.X.X/ where X is a number
semver = `\/(\d+\.\d+\.\d+)\/`
// without the ending '"' pre-release folders would be tried and break.
semver = `\/(\d+\.\d+\.\d+)\"`
}
r, _ := regexp.Compile(semver)
for i := range result {
if r.MatchString(result[i]) {
str := r.FindString(result[i])
trimstr := strings.Trim(str, "/") // remove "/" from /X.X.X/
trimstr := strings.Trim(str, "/\"") //remove "/" from /X.X.X/
tfVersionList.tflist = append(tfVersionList.tflist, trimstr)
}
}
Expand Down

0 comments on commit e87de16

Please sign in to comment.