feat: hide image links from messages and improve overall handling of links
This commit is contained in:
parent
69d6020865
commit
7b1e636187
|
@ -20,8 +20,8 @@ async function updateMessages(id) {
|
|||
const timeParagraph = document.createElement("p");
|
||||
const { creator, content, id, created } = message;
|
||||
|
||||
// Check if the message content contains any links that are not image links
|
||||
const linkRegex = /(https?:\/\/[^\s]+(?<!\.(?:png|apng|webp|svg|jpg|jpeg|gif)))/gi;
|
||||
// Check if the message content contains any links that are not image links and hide image links
|
||||
const linkRegex = /(https?:\/\/[^\s]+(?<!\.(?:png|apng|webp|svg|jpg|jpeg|gif)))(?=\s|$)|(?<=\s|^)(https?:\/\/(?:cdn\.discordapp\.com|media\.discordapp\.net|media\.tenor\.com|i\.imgur\.com|burger\.ctaposter\.xyz)\/.+?\.(?:png|apng|webp|svg|jpg|jpeg|gif))(?=$|\s)/gi;
|
||||
let messageContent = content.replace(linkRegex, "<a href='$1' target='_blank'>$1</a>");
|
||||
|
||||
messageParagraph.innerHTML = `${creator.username}: ${messageContent}`;
|
||||
|
|
Reference in New Issue