fix: image handling when image url received is not a path with an extension

This commit is contained in:
Julian Lam
2025-08-06 13:50:08 -04:00
parent 3895a0590c
commit b4ff79061f

View File

@@ -84,7 +84,7 @@ Mocks._normalize = async (object) => {
content = '<em>This post did not contain any content.</em>'; content = '<em>This post did not contain any content.</em>';
} }
switch (true) { switch (true) { // image handling
case image && image.hasOwnProperty('url') && !!image.url: { case image && image.hasOwnProperty('url') && !!image.url: {
image = image.url; image = image.url;
break; break;
@@ -101,7 +101,8 @@ Mocks._normalize = async (object) => {
} }
if (image) { if (image) {
const parsed = new URL(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}`); activitypub.helpers.log(`[activitypub/mocks.post] Received image not identified as image due to MIME type: ${image}`);
image = null; image = null;
} }