fix: use >= in compareVersions fallback to handle equal/unparseable versions (#635)

compareVersions returns 0 for both genuinely equal versions and
unparseable strings. In the localIndex === -1 fallback path, skipping
on >= 0 (instead of just > 0) avoids showing stale rich cards when
the version relationship is ambiguous.
This commit is contained in:
Jinjing 2026-04-14 10:33:25 -07:00 committed by GitHub
parent bc20035652
commit 4479e4c0eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -106,8 +106,14 @@ export async function fetchChangelog(
if (localIndex < i) {
continue
}
} else if (compareVersions(localVersion, candidate.version) > 0) {
// localVersion is newer than this candidate — user already passed it.
} else if (compareVersions(localVersion, candidate.version) >= 0) {
// localVersion is newer than (or same as) this candidate — user already
// passed it. Why >=: compareVersions returns 0 both for genuinely equal
// versions and for unparseable strings. In the localIndex === -1 path,
// equal means localVersion literally matches the candidate but wasn't
// found by findIndex (shouldn't happen), and unparseable means we can't
// determine the relationship. Either way, skipping is the safe default
// to avoid showing stale content.
continue
}