Skip to content

Commit

Permalink
Merge pull request #22 from pdcmoreira/improve-download-options
Browse files Browse the repository at this point in the history
Improve download options' texts
  • Loading branch information
Ovenoboyo authored Sep 14, 2023
2 parents 3a354bd + 52a4150 commit 20dbb65
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion assets/js/downloadUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ function getSanitizedLinuxName (ext) {
}
}

function getSanitizedName(release) {
if (release.url.includes('linux')) {
return getSanitizedLinuxName(release.ext)
}

const match = release.url.match(/^.*\/.*-\d+\.\d+\.\d+-([^.]*)\.(.*)$/)

return match && match.length === 3 ? `${match[1]}.${match[2]}` : release.ext
}

export async function setupDownloadButton () {
const os = getOS();
const downloadParent = document.getElementById("downloads");
Expand Down Expand Up @@ -147,7 +157,7 @@ export async function setupDownloadButton () {
for (const release of releases) {
const optionDiv = document.createElement('div')
optionDiv.classList.add('option')
optionDiv.innerHTML = `${getSanitizedLinuxName(release.ext)}`
optionDiv.innerHTML = `${getSanitizedName(release)}`
optionsContainer.appendChild(optionDiv)

optionDiv.onclick = () => window.open(release.url)
Expand Down

0 comments on commit 20dbb65

Please sign in to comment.