Skip to content

Commit

Permalink
js: Default to linux-amd64 and fix split() call on platform (#187)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
francislavoie authored Aug 13, 2021
1 parent 5f09f05 commit a7861e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
<div>
<div>
<b>Platform:</b>
<select size="1" id="platform">
<option></option>
<select size="1" id="platform" selected="linux-amd64">
<option value="dragonfly-amd64">Dragonfly amd64</option>
<option value="freebsd-amd64">FreeBSD amd64</option>
<option value="freebsd-arm-6">FreeBSD arm 6</option>
Expand Down
16 changes: 10 additions & 6 deletions src/resources/js/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a7861e9

Please sign in to comment.