From a9507db73922884a705c860eb7dc882e9282eafd Mon Sep 17 00:00:00 2001 From: Micah Flatt Date: Mon, 9 May 2022 16:22:37 -0500 Subject: [PATCH] Tweaking URL regex based on comment from aderuelle --- lib/list_versions.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/list_versions.go b/lib/list_versions.go index 930ae18c..463cbf1e 100644 --- a/lib/list_versions.go +++ b/lib/list_versions.go @@ -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) } }