Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app/routes/crate/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,29 @@ export default Route.extend({
.get('versions')
.then(versions => {
const latestStableVersion = versions.find(version => {
// Find the latest version that is stable AND not-yanked.
if (!isUnstableVersion(version.get('num')) && !version.get('yanked')) {
return version;
}
});

if (latestStableVersion == null) {
// If no stable version exists, fallback to `maxVersion`
params.version_num = maxVersion;
// Cannot find any version that is stable AND not-yanked.
// The fact that "maxVersion" itself cannot be found means that
// we have to fall back to the latest one that is unstable....
const latestUnyankedVersion = versions.find(version => {
// Find the latest version that is stable AND not-yanked.
if (!version.get('yanked')) {
return version;
}
});

if (latestStableVersion == null) {
// There's not even any unyanked version...
params.version_num = maxVersion;
} else {
params.version_num = latestUnyankedVersion;
}
} else {
params.version_num = latestStableVersion.get('num');
}
Expand Down