From b4ff79061f8018e6d17a476567c256c88e5fa1ac Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 6 Aug 2025 13:50:08 -0400 Subject: [PATCH] fix: image handling when image url received is not a path with an extension --- src/activitypub/mocks.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js index e5a8e8e363..e1e9d82b69 100644 --- a/src/activitypub/mocks.js +++ b/src/activitypub/mocks.js @@ -84,7 +84,7 @@ Mocks._normalize = async (object) => { content = 'This post did not contain any content.'; } - switch (true) { + switch (true) { // image handling case image && image.hasOwnProperty('url') && !!image.url: { image = image.url; break; @@ -101,7 +101,8 @@ Mocks._normalize = async (object) => { } if (image) { const parsed = new URL(image); - if (!mime.getType(parsed.pathname).startsWith('image/')) { + const type = mime.getType(parsed.pathname); + if (!type || type.startsWith('image/')) { activitypub.helpers.log(`[activitypub/mocks.post] Received image not identified as image due to MIME type: ${image}`); image = null; }