File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,34 @@ export default Ember.Route.extend({
10
10
const controller = this . controllerFor ( this . routeName ) ;
11
11
const maxVersion = crate . get ( 'max_version' ) ;
12
12
13
- // Fall back to the crate's `max_version` property
13
+ const isUnstableVersion = ( version ) => {
14
+ const unstableFlags = [ 'alpha' , 'beta' ] ;
15
+
16
+ return unstableFlags . some ( ( flag ) => {
17
+ return version . includes ( flag ) ;
18
+ } ) ;
19
+ } ;
20
+
21
+ // Fallback to the crate's last stable version
14
22
if ( ! requestedVersion ) {
15
- params . version_num = maxVersion ;
23
+ if ( isUnstableVersion ( maxVersion ) ) {
24
+ crate . get ( 'versions' ) . then ( versions => {
25
+ const latestStableVersion = versions . find ( version => {
26
+ if ( ! isUnstableVersion ( version . get ( 'num' ) ) ) {
27
+ return version ;
28
+ }
29
+ } ) ;
30
+
31
+ if ( latestStableVersion == null ) {
32
+ // If no stable version exists, fallback to `maxVersion`
33
+ params . version_num = maxVersion ;
34
+ } else {
35
+ params . version_num = latestStableVersion . get ( 'num' ) ;
36
+ }
37
+ } ) ;
38
+ } else {
39
+ params . version_num = maxVersion ;
40
+ }
16
41
}
17
42
18
43
controller . set ( 'crate' , crate ) ;
You can’t perform that action at this time.
0 commit comments