This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-website.git
The following commit(s) were added to refs/heads/main by this push:
new e732cd2 Fix downloads script for mirror selection
e732cd2 is described below
commit e732cd2162e2fae08997220cf0b6b660fb640037
Author: Christopher Tubbs <[email protected]>
AuthorDate: Thu Apr 22 15:13:43 2021 -0400
Fix downloads script for mirror selection
Check that http, ftp, or backup sections actually exist in the returned
JSON before trying to read them as an array.
---
pages/downloads.md | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/pages/downloads.md b/pages/downloads.md
index 9d94664..ab36b3a 100644
--- a/pages/downloads.md
+++ b/pages/downloads.md
@@ -17,21 +17,27 @@ var mirrorsCallback = function(json) {
htmlContent += '<optgroup label="Preferred Mirror (based on location)">';
htmlContent += '<option selected="selected">' + json.preferred + '</option>';
htmlContent += '</optgroup>';
- htmlContent += '<optgroup label="HTTP Mirrors">';
- for (var i = 0; i < json.http.length; i++) {
- htmlContent += '<option>' + json.http[i] + '</option>';
+ if (json.hasOwnProperty('http')) {
+ htmlContent += '<optgroup label="HTTP Mirrors">';
+ for (var i = 0; i < json.http.length; i++) {
+ htmlContent += '<option>' + json.http[i] + '</option>';
+ }
+ htmlContent += '</optgroup>';
}
- htmlContent += '</optgroup>';
- htmlContent += '<optgroup label="FTP Mirrors">';
- for (var i = 0; i < json.ftp.length; i++) {
- htmlContent += '<option>' + json.ftp[i] + '</option>';
+ if (json.hasOwnProperty('ftp')) {
+ htmlContent += '<optgroup label="FTP Mirrors">';
+ for (var i = 0; i < json.ftp.length; i++) {
+ htmlContent += '<option>' + json.ftp[i] + '</option>';
+ }
+ htmlContent += '</optgroup>';
}
- htmlContent += '</optgroup>';
- htmlContent += '<optgroup label="Backup Mirrors">';
- for (var i = 0; i < json.backup.length; i++) {
- htmlContent += '<option>' + json.backup[i] + '</option>';
+ if (json.hasOwnProperty('backup')) {
+ htmlContent += '<optgroup label="Backup Mirrors">';
+ for (var i = 0; i < json.backup.length; i++) {
+ htmlContent += '<option>' + json.backup[i] + '</option>';
+ }
+ htmlContent += '</optgroup>';
}
- htmlContent += '</optgroup>';
htmlContent += '</select></div></div>';
$("#mirror_selection").html(htmlContent);