diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 5349f79..7d20d7f 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -465,7 +465,11 @@ async function processUrl(msg, url) { .then((buf) => Buffer.from(buf)); files.push({ - name: attachment.type.replace("/", "."), + name: + attachment.type.indexOf("/") > -1 + ? attachment.type.replace("/", ".") + : attachment.type + + (url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp4"), contents: file, }); } @@ -492,11 +496,15 @@ async function processUrl(msg, url) { .then((buf) => Buffer.from(buf)); files.push({ - name: attachment.type - .replace("/", ".") - .replace("mpeg", "mp3") - .replace("vnd.wave", "wav") - .replace("x-wav", "wav"), + name: + attachment.type.indexOf("/") > -1 + ? attachment.type + .replace("/", ".") + .replace("mpeg", "mp3") + .replace("vnd.wave", "wav") + .replace("x-wav", "wav") + : attachment.type + + (url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp3"), contents: file, }); }