Skip to content

Commit 370b9c2

Browse files
committed
Consider any version with chars after major.minor.patch as unstable
— Elliot Jackson <elliot@elliotekj.com>
1 parent 9b6ddf8 commit 370b9c2

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

app/routes/crate/version.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@ export default Ember.Route.extend({
1010
const controller = this.controllerFor(this.routeName);
1111
const maxVersion = crate.get('max_version');
1212

13-
const isUnstableVersion = (version) => {
14-
const unstableFlags = ['alpha', 'beta'];
13+
const isUnstableVersion = version => {
14+
const versionLen = version.length;
15+
let majorMinorPatchChars = 0;
16+
let result = false;
1517

16-
return unstableFlags.some((flag) => {
17-
return version.indexOf(flag) > -1;
18-
});
18+
for (let i = 0; i < versionLen; i++) {
19+
const char = version.charAt(i);
20+
21+
if (!isNaN(parseInt(char)) || char === '.') {
22+
majorMinorPatchChars++;
23+
} else {
24+
break;
25+
}
26+
}
27+
28+
if (versionLen !== majorMinorPatchChars) {
29+
result = true;
30+
}
31+
32+
return result;
1933
};
2034

2135
// Fallback to the crate's last stable version

0 commit comments

Comments
 (0)