mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-07 15:38:22 +08:00
fix(update): strip hyphenated suffix from version string during comparison
When running a custom build or pre-release version (e.g. v0.1.183-custom), parseVersion failed to parse the patch segment because of the non-numeric suffix, causing compareVersions to incorrectly report an available update. This commit strips any hyphenated suffix before splitting SemVer components. Signed-off-by: WUJI-Labs <zoujincool@gmail.com>
This commit is contained in:
@@ -655,6 +655,9 @@ func compareVersions(current, latest string) int {
|
||||
|
||||
func parseVersion(v string) [3]int {
|
||||
v = strings.TrimPrefix(v, "v")
|
||||
if idx := strings.IndexByte(v, '-'); idx != -1 {
|
||||
v = v[:idx]
|
||||
}
|
||||
parts := strings.Split(v, ".")
|
||||
result := [3]int{0, 0, 0}
|
||||
for i := 0; i < len(parts) && i < 3; i++ {
|
||||
|
||||
Reference in New Issue
Block a user