From a7861e98f7fca355dcc66202f46ff8ecf7d64e4f Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 13 Aug 2021 16:59:45 -0400 Subject: [PATCH] js: Default to linux-amd64 and fix split() call on platform (#187) In certain cases where the platform cannot be automatically determined, we should at least populate a default so that the download page doesn't break. --- src/download.html | 3 +-- src/resources/js/download.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/download.html b/src/download.html index afa53f6..391f3b1 100644 --- a/src/download.html +++ b/src/download.html @@ -23,8 +23,7 @@
Platform: - diff --git a/src/resources/js/download.js b/src/resources/js/download.js index d7673cd..09639b9 100644 --- a/src/resources/js/download.js +++ b/src/resources/js/download.js @@ -169,11 +169,11 @@ $(function() { }); }) -// autoPlatform choooses the platform in the list that best +// autoPlatform chooses the platform in the list that best // matches the user's browser, if it's available. function autoPlatform() { // assume 32-bit linux, then change OS and architecture if justified - var os = "linux", arch = "386", arm = ""; + var os = "linux", arch = "amd64", arm = ""; // change os if (/Macintosh/i.test(navigator.userAgent)) { @@ -215,11 +215,15 @@ function autoPlatform() { } function getDownloadLink() { + // make sure we at least have a default, + // in the case that autoPlatform() failed + var platformString = $('#platform').val(); + if (!platformString) { + platformString = "linux-amd64" + } + // get platform components - var platformParts = $('#platform').val().split("-"); - var os = platformParts[0]; - var arch = platformParts[1]; - var arm = platformParts.length > 2 ? platformParts[2] : ""; + var [os, arch, arm = ""] = platformString.split("-"); var qs = new URLSearchParams(); if (os) qs.set("os", os);