Fix pre-release and release candidate version checking

This commit is contained in:
comp500 2020-06-20 02:38:07 +01:00
parent da779d55cd
commit d789066039

View File

@ -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 ")
for _, name := range snapshotNames {
index := strings.Index(mcVersion, name)
if index > -1 {
return mcVersion[:index] + "-Snapshot"
}
index = strings.Index(mcVersion, " Pre-release ")
if index > -1 {
return mcVersion[:index] + "-Snapshot"
}
matches := snapshotVersionRegex.FindStringSubmatch(mcVersion)