Skip to content

Commit

Permalink
Tweaking URL regex based on comment from aderuelle
Browse files Browse the repository at this point in the history
  • Loading branch information
micahflattbuilt committed May 9, 2022
1 parent 092ccf5 commit a9507db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/list_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ func GetTFList(mirrorURL string, preRelease bool) ([]string, error) {
var semver string
if preRelease == true {
// 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 == false {
// 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 a9507db

Please sign in to comment.