From d78906603947fad5c91d452e9c8e9c25b995b601 Mon Sep 17 00:00:00 2001 From: comp500 Date: Sat, 20 Jun 2020 02:38:07 +0100 Subject: [PATCH] Fix pre-release and release candidate version checking --- curseforge/curseforge.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/curseforge/curseforge.go b/curseforge/curseforge.go index 6efb4f2..3fb520a 100644 --- a/curseforge/curseforge.go +++ b/curseforge/curseforge.go @@ -31,18 +31,14 @@ var fileIDRegexes = [...]*regexp.Regexp{ var snapshotVersionRegex = regexp.MustCompile("(?:Snapshot )?(\\d+)w0?(0|[1-9]\\d*)([a-z])") +var snapshotNames = [...]string{"-pre", " Pre-Release ", " Pre-release ", "-rc"} + func getCurseforgeVersion(mcVersion string) string { - if strings.HasSuffix(mcVersion, "-pre") { - return strings.TrimSuffix(mcVersion, "-pre") + "-Snapshot" - } - // Mojang why must it be this way - index := strings.Index(mcVersion, " Pre-Release ") - if index > -1 { - return mcVersion[:index] + "-Snapshot" - } - index = strings.Index(mcVersion, " Pre-release ") - if index > -1 { - return mcVersion[:index] + "-Snapshot" + for _, name := range snapshotNames { + index := strings.Index(mcVersion, name) + if index > -1 { + return mcVersion[:index] + "-Snapshot" + } } matches := snapshotVersionRegex.FindStringSubmatch(mcVersion)