From a16f49b86afcc487314ed6881fe2a3a8585c21aa Mon Sep 17 00:00:00 2001 From: iiPython Date: Tue, 26 Nov 2024 17:31:01 -0600 Subject: [PATCH] fix images not loading due to invalid conditions --- nightwatch/web/js/nightwatch.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nightwatch/web/js/nightwatch.js b/nightwatch/web/js/nightwatch.js index 9aae281..93214f1 100644 --- a/nightwatch/web/js/nightwatch.js +++ b/nightwatch/web/js/nightwatch.js @@ -92,6 +92,7 @@ const FILE_HANDLER = new FileHandler(); // Construct text/attachment let attachment = message.message, classlist = "message-content"; + let raw_attachment = attachment; if (attachment.toLowerCase().match(/^https:\/\/[\w\d./-]+.(?:avifs?|a?png|jpe?g|jfif|webp|ico|gif|svg)(?:\?.+)?$/)) { attachment = `![untitled](${attachment})`; } @@ -119,7 +120,7 @@ const FILE_HANDLER = new FileHandler(); }; // Check for files - const file_match = attachment.match(new RegExp(`^https?:\/\/${address}\/file\/([a-zA-Z0-9_-]{21})\/.*$`)); + const file_match = raw_attachment.match(new RegExp(`^https?:\/\/${address}\/file\/([a-zA-Z0-9_-]{21})\/.*$`)); if (file_match) { function bytes_to_human(size) { const i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); @@ -129,7 +130,7 @@ const FILE_HANDLER = new FileHandler(); if (response.code === 200) { const mimetype = FILE_HANDLER.mimetype(response.data.name); if (["avif", "avifs", "png", "apng", "jpg", "jpeg", "jfif", "webp", "ico", "gif", "svg"].includes(mimetype.toLowerCase())) { - attachment = `${response.data.name}]`; + attachment = `${response.data.name}`; } else { attachment = `
${response.data.name} ${mimetype}