fix getCommentMediaInfo

This commit is contained in:
plebbitor
2023-04-12 17:09:12 +02:00
parent 8cc5fdd4b5
commit ba6fe429b0
+10 -2
View File
@@ -11,7 +11,15 @@ const getCommentMediaInfo = (comment) => {
};
}
if (comment?.link) {
const mime = extName(new URL(comment?.link).pathname.replace('/', ''))[0]?.mime
try {
new URL(comment.link);
} catch (error) {
console.error("Invalid URL:", comment.link);
return;
}
const mime = extName(new URL(comment?.link).pathname.replace('/', ''))[0]?.mime;
if (mime?.startsWith('image')) {
return {
url: comment.link,
@@ -35,4 +43,4 @@ const getCommentMediaInfo = (comment) => {
}
};
export default getCommentMediaInfo;
export default getCommentMediaInfo;