Skip to content

Commit 20dbb65

Browse files
authored
Merge pull request #22 from pdcmoreira/improve-download-options
Improve download options' texts
2 parents 3a354bd + 52a4150 commit 20dbb65

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

assets/js/downloadUtils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ function getSanitizedLinuxName (ext) {
105105
}
106106
}
107107

108+
function getSanitizedName(release) {
109+
if (release.url.includes('linux')) {
110+
return getSanitizedLinuxName(release.ext)
111+
}
112+
113+
const match = release.url.match(/^.*\/.*-\d+\.\d+\.\d+-([^.]*)\.(.*)$/)
114+
115+
return match && match.length === 3 ? `${match[1]}.${match[2]}` : release.ext
116+
}
117+
108118
export async function setupDownloadButton () {
109119
const os = getOS();
110120
const downloadParent = document.getElementById("downloads");
@@ -147,7 +157,7 @@ export async function setupDownloadButton () {
147157
for (const release of releases) {
148158
const optionDiv = document.createElement('div')
149159
optionDiv.classList.add('option')
150-
optionDiv.innerHTML = `${getSanitizedLinuxName(release.ext)}`
160+
optionDiv.innerHTML = `${getSanitizedName(release)}`
151161
optionsContainer.appendChild(optionDiv)
152162

153163
optionDiv.onclick = () => window.open(release.url)

0 commit comments

Comments
 (0)