Skip to content

Commit

Permalink
fix(post): some links to images could be embedded as videos
Browse files Browse the repository at this point in the history
  • Loading branch information
plebeius-eth committed Oct 11, 2024
1 parent 561e395 commit 46e1189
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/lib/utils/media-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ export const getLinkMediaInfo = memoize(
}

try {
const fileName = url.pathname.slice(url.pathname.lastIndexOf('/') + 1).toLowerCase();
mime = extName(fileName)[0]?.mime;
if (mime) {
if (mime.startsWith('image')) {
type = mime === 'image/gif' ? 'gif' : 'image';
} else if (mime.startsWith('video')) {
type = 'video';
} else if (mime.startsWith('audio')) {
type = 'audio';
const fileName = url.pathname.split('/').pop() || '';
if (fileName.includes('.')) {
mime = extName(fileName)[0]?.mime;
if (mime) {
if (mime.startsWith('image')) {
type = mime === 'image/gif' ? 'gif' : 'image';
} else if (mime.startsWith('video')) {
type = 'video';
} else if (mime.startsWith('audio')) {
type = 'audio';
}
}
}

Expand Down

0 comments on commit 46e1189

Please sign in to comment.