Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 713deb6

Browse files
committed
šŸ› Fix bug where a version starting with would make the version comparison fails
1 parent 43e0b8c commit 713deb6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ā€Žstatic/pypi_checker.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
function semverCompare(a, b) {
2+
// Remove leading letters, such as `v` (`v4.23` becomes `4.23`)
3+
const clean = (v) => v.replace(/^[a-zA-Z]+/, "");
4+
a = clean(a);
5+
b = clean(b);
6+
7+
// Actual comparison
28
if (a.startsWith(b + "-")) return -1
39
if (b.startsWith(a + "-")) return 1
410
return a.localeCompare(b, undefined, { numeric: true, sensitivity: "case", caseFirst: "upper" })

0 commit comments

Comments
Ā (0)