avatar brianteeman
brianteeman
25 Mar 2022

Steps to reproduce the issue

In an article use the xtd-editor media button to open the media manager.
Upload a pdf file that has spaces in the name eg "20 May 2021 Minutes.pdf"
Insert the file with the download option
Repeat the above with another pdf that this time has no spaces in it eg "20May2021Minutes.pdf"

image

Expected result

Clickable links to download the pdf with the filename in the text

Actual result

The file with spaces in it loses everything between the first and second space

image

Additional comments

I believe the relevant code is

} else if (Joomla.editors.instances[editor].getSelection() !== '') {
outputText = `<a download href="${Joomla.selectedMediaFile.url}">${Joomla.editors.instances[editor].getSelection()}</a>`;
} else {
const name = /([\w-]+)\./.exec(Joomla.selectedMediaFile.url);
outputText = `<a download href="${Joomla.selectedMediaFile.url}">${Joomla.Text._('JFIELD_MEDIA_DOWNLOAD_FILE').replace('{file}', name[1])}</a>`;
}

avatar brianteeman brianteeman - open - 25 Mar 2022
avatar dgrammatiko
dgrammatiko - comment - 25 Mar 2022
 } else { 
   const name =  Joomla.selectedMediaFile.url.substr(0, Joomla.selectedMediaFile.url.lastIndexOf('.'));
   outputText = `<a download href="${Joomla.selectedMediaFile.url}">${Joomla.Text._('JFIELD_MEDIA_DOWNLOAD_FILE').replace('{file}', name)}</a>`; 
 } 
avatar brianteeman
brianteeman - comment - 25 Mar 2022

@dgrammatiko almost. It is now displayed with the %20 characters

avatar dgrammatiko
dgrammatiko - comment - 25 Mar 2022
const name =  Joomla.selectedMediaFile.url.substr(0, Joomla.selectedMediaFile.url.lastIndexOf('.')).replace(/\%20/, ' ');
avatar brianteeman
brianteeman - comment - 25 Mar 2022

Still not right. I will leave it to someone else to fix

avatar anmode
anmode - comment - 4 Apr 2022

could I solve this?

avatar brianteeman brianteeman - change - 22 Jun 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-06-22 16:00:24
Closed_By brianteeman
avatar brianteeman brianteeman - close - 22 Jun 2022

Add a Comment

Login with GitHub to post a comment