Skip to content

Commit 4a0ea08

Browse files
committed
Fix version comparison
1 parent 9d47a07 commit 4a0ea08

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

chrome/player/utils/UpdateChecker.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ export class UpdateChecker {
1919
const current = currentVersion.split('.');
2020
const latest = latestVersion.split('.');
2121

22-
for (let i = 0; i < latest.length; i++) {
23-
const c = parseInt(current[i]);
24-
const l = parseInt(latest[i]);
22+
const maxLen = Math.max(current.length, latest.length);
23+
for (let i = 0; i < maxLen; i++) {
24+
const c = parseInt(current[i] || '0', 10);
25+
const l = parseInt(latest[i] || '0', 10);
2526
if (isNaN(l) || isNaN(c)) {
2627
return false;
27-
} else if (c < l) {
28+
}
29+
if (c < l) {
2830
return true;
29-
} else if (c > l) {
31+
}
32+
if (c > l) {
3033
return false;
3134
}
3235
}

0 commit comments

Comments
 (0)