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 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 { func getCurseforgeVersion(mcVersion string) string {
if strings.HasSuffix(mcVersion, "-pre") { for _, name := range snapshotNames {
return strings.TrimSuffix(mcVersion, "-pre") + "-Snapshot" index := strings.Index(mcVersion, name)
} if index > -1 {
// Mojang why must it be this way return mcVersion[:index] + "-Snapshot"
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"
} }
matches := snapshotVersionRegex.FindStringSubmatch(mcVersion) matches := snapshotVersionRegex.FindStringSubmatch(mcVersion)