Some array.slice to array.startsWith and cleanup some JavaScript code

This commit is contained in:
the-djmaze 2022-10-26 16:38:39 +02:00
parent 3903a37b64
commit ffcc86805a
8 changed files with 83 additions and 146 deletions

View file

@ -177,7 +177,7 @@ export class AttachmentModel extends AbstractModel {
const localEvent = event.originalEvent || event;
if (attachment && localEvent && localEvent.dataTransfer && localEvent.dataTransfer.setData) {
let link = this.linkDownload();
if ('http' !== link.slice(0, 4)) {
if (!link.startsWith('http')) {
link = location.protocol + '//' + location.host + location.pathname + link;
}
localEvent.dataTransfer.setData('DownloadURL', this.mimeType + ':' + this.fileName + ':' + link);