diff --git a/web/api-common/app-global.js b/web/api-common/app-global.js
index a5ae6d6d..2696cb34 100644
--- a/web/api-common/app-global.js
+++ b/web/api-common/app-global.js
@@ -81,12 +81,13 @@ function download(name, closeCallback, closeCallbackData) {
fileParts = data.filename.split('?');
fileParts = fileParts[0].split('.');
- if (jQuery.inArray(fileParts[fileParts.length - 1], viewableFiles) >= 0) {
+
+ if (jQuery.inArray(data.ext, viewableFiles) >= 0) {
const win = window.open(data.filename, '_blank');
win.focus();
} else {
link = `Download File `;
- if (jQuery.inArray(fileParts[fileParts.length - 1], viewableImages) >= 0) {
+ if (jQuery.inArray(data.ext, viewableImages) >= 0) {
link += `
`;
}
modJs.showMessage('Download File Attachment', link, closeCallback, closeCallbackData);