Fix #5476: 修复无法归一化版本号 "1.16.2 Pre-release 1" 的问题 (#5480)

This commit is contained in:
Glavo
2026-02-07 21:49:56 +08:00
committed by GitHub
parent 3fdf21fcd5
commit 9f2874c12b
2 changed files with 6 additions and 0 deletions

View File

@@ -348,6 +348,11 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
needNormalize = true;
releaseType = ReleaseType.PRE_RELEASE;
eaVersion = VersionNumber.asVersion(suffix.substring(" Pre-Release ".length()));
} else if (suffix.startsWith(" Pre-release ")) {
// https://github.com/HMCL-dev/HMCL/issues/5476
needNormalize = true;
releaseType = ReleaseType.PRE_RELEASE;
eaVersion = VersionNumber.asVersion(suffix.substring(" Pre-release ".length()));
} else if (suffix.startsWith("-rc")) {
releaseType = ReleaseType.RELEASE_CANDIDATE;
eaVersion = VersionNumber.asVersion(suffix.substring("-rc".length()));

View File

@@ -450,6 +450,7 @@ public final class GameVersionNumberTest {
assertNormalized("1.16_combat-4", "Combat Test 8");
assertNormalized("1.16_combat-5", "Combat Test 8b");
assertNormalized("1.16_combat-6", "Combat Test 8c");
assertNormalized("1.16.2-pre1", "1.16.2 Pre-release 1"); // https://github.com/HMCL-dev/HMCL/pull/5476
assertNormalized("1.18_experimental-snapshot-1", "1.18 Experimental Snapshot 1");
assertNormalized("1.18_experimental-snapshot-2", "1.18 experimental snapshot 2");
assertNormalized("1.18_experimental-snapshot-3", "1.18 experimental snapshot 3");