From 4f9ff6bde96b21fdc8d0be655a321c69df90ee40 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Sun, 5 Jan 2020 21:43:47 -0800 Subject: [PATCH 1/3] Fix comment: no longer finding stable versions --- app/routes/crate/version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/crate/version.js b/app/routes/crate/version.js index 5ad67fd5d0f..98235715d59 100644 --- a/app/routes/crate/version.js +++ b/app/routes/crate/version.js @@ -55,7 +55,7 @@ export default Route.extend({ // 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. + // Find the latest version that is not-yanked. if (!version.get('yanked')) { return version; } From acd6c8e1aa7b896172c0dd1f3fc4a22ad2f282ad Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Sun, 5 Jan 2020 21:45:18 -0800 Subject: [PATCH 2/3] Fix fallback to unstable version It was checking the result of the previous search for a stable unyanked version. --- app/routes/crate/version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/crate/version.js b/app/routes/crate/version.js index 98235715d59..531e7b27130 100644 --- a/app/routes/crate/version.js +++ b/app/routes/crate/version.js @@ -61,7 +61,7 @@ export default Route.extend({ } }); - if (latestStableVersion == null) { + if (latestUnyankedVersion == null) { // There's not even any unyanked version... params.version_num = maxVersion; } else { From bd3c0c0a0f1fa591f96c884fe965142b5f58c9c7 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Sun, 5 Jan 2020 21:46:20 -0800 Subject: [PATCH 3/3] Use Array#find in a less misleading way It takes a predicate. --- app/routes/crate/version.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/routes/crate/version.js b/app/routes/crate/version.js index 531e7b27130..a79633978b8 100644 --- a/app/routes/crate/version.js +++ b/app/routes/crate/version.js @@ -45,9 +45,7 @@ export default Route.extend({ .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; - } + return !isUnstableVersion(version.get('num')) && !version.get('yanked'); }); if (latestStableVersion == null) { @@ -56,9 +54,7 @@ export default Route.extend({ // we have to fall back to the latest one that is unstable.... const latestUnyankedVersion = versions.find(version => { // Find the latest version that is not-yanked. - if (!version.get('yanked')) { - return version; - } + return !version.get('yanked'); }); if (latestUnyankedVersion == null) {