fix(post): some links to images could be embedded as videos

same as https://github.com/plebbit/seedit/issues/385
This commit is contained in:
Tom (plebeius.eth)
2024-10-11 22:01:33 +02:00
parent 561e395256
commit 46e1189711
+11 -9
View File
@@ -80,15 +80,17 @@ export const getLinkMediaInfo = memoize(
} }
try { try {
const fileName = url.pathname.slice(url.pathname.lastIndexOf('/') + 1).toLowerCase(); const fileName = url.pathname.split('/').pop() || '';
mime = extName(fileName)[0]?.mime; if (fileName.includes('.')) {
if (mime) { mime = extName(fileName)[0]?.mime;
if (mime.startsWith('image')) { if (mime) {
type = mime === 'image/gif' ? 'gif' : 'image'; if (mime.startsWith('image')) {
} else if (mime.startsWith('video')) { type = mime === 'image/gif' ? 'gif' : 'image';
type = 'video'; } else if (mime.startsWith('video')) {
} else if (mime.startsWith('audio')) { type = 'video';
type = 'audio'; } else if (mime.startsWith('audio')) {
type = 'audio';
}
} }
} }