fix: wrap links inside of <a> for convenience
This commit is contained in:
parent
48321233c3
commit
df75e02efc
|
@ -20,7 +20,11 @@ async function updateMessages(id) {
|
||||||
const timeParagraph = document.createElement("p");
|
const timeParagraph = document.createElement("p");
|
||||||
const { creator, content, id, created } = message;
|
const { creator, content, id, created } = message;
|
||||||
|
|
||||||
messageParagraph.appendChild(document.createTextNode(`${creator.username}: ${content}`));
|
// 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;
|
||||||
|
let messageContent = content.replace(linkRegex, "<a href='$1' target='_blank'>$1</a>");
|
||||||
|
|
||||||
|
messageParagraph.innerHTML = `${creator.username}: ${messageContent}`;
|
||||||
messageParagraph.classList.add("messageParagraph");
|
messageParagraph.classList.add("messageParagraph");
|
||||||
messageParagraph.id = `messageParagraph${id}`;
|
messageParagraph.id = `messageParagraph${id}`;
|
||||||
messageParagraph.appendChild(timeParagraph);
|
messageParagraph.appendChild(timeParagraph);
|
||||||
|
|
Reference in New Issue