Skip to content

Commit 9ab608e

Browse files
authored
[5.2] Fix media downloads with spaces followup of #37396 (#44745)
1 parent 53f4543 commit 9ab608e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

build/media_source/system/js/fields/joomla-media-select.w-c.es6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ const insertAsOther = (media, editor, fieldClass, type) => {
243243
} else if (editorInst.getSelection() !== '') {
244244
outputText = `<a download href="${Joomla.selectedMediaFile.url}">${editorInst.getSelection()}</a>`;
245245
} else {
246-
const name = /([\w-]+)\./.exec(Joomla.selectedMediaFile.url);
247-
outputText = `<a download href="${Joomla.selectedMediaFile.url}">${Joomla.Text._('JFIELD_MEDIA_DOWNLOAD_FILE').replace('{file}', name[1])}</a>`;
246+
const name = Joomla.selectedMediaFile.url.substr(0, Joomla.selectedMediaFile.url.lastIndexOf('.')).replace(/%20/g, ' ').split('/').pop();
247+
outputText = `<a download href="${Joomla.selectedMediaFile.url}">${Joomla.Text._('JFIELD_MEDIA_DOWNLOAD_FILE').replace('{file}', name)}</a>`;
248248
}
249249
}
250250

0 commit comments

Comments
 (0)