fix(post): a non-direct link could be marked as media instead of webpage

This commit is contained in:
Tom (plebeius.eth)
2024-10-12 17:10:13 +02:00
parent 088ec8428b
commit e9280ac84c
+4 -3
View File
@@ -80,9 +80,7 @@ export const getLinkMediaInfo = memoize(
} }
try { try {
const fileName = url.pathname.split('/').pop() || ''; mime = extName(new URL(link).pathname.toLowerCase().replace('/', ''))[0]?.mime;
if (fileName.includes('.')) {
mime = extName(fileName)[0]?.mime;
if (mime) { if (mime) {
if (mime.startsWith('image')) { if (mime.startsWith('image')) {
type = mime === 'image/gif' ? 'gif' : 'image'; type = mime === 'image/gif' ? 'gif' : 'image';
@@ -92,6 +90,9 @@ export const getLinkMediaInfo = memoize(
type = 'audio'; type = 'audio';
} }
} }
if (!url.pathname.includes('.')) {
type = 'webpage';
} }
if (canEmbed(url) || url.host.startsWith('yt.')) { if (canEmbed(url) || url.host.startsWith('yt.')) {