Skip to content

Commit

Permalink
Don't embed links in <>
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake authored and MaddyUnderStars committed Jul 3, 2024
1 parent 5f9c6b0 commit 0ac8888
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api/util/handlers/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const allow_empty = false;
// TODO: embed gifs/videos/images

const LINK_REGEX =
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;
/<?https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)>?/g;

export async function handleMessage(opts: MessageOptions): Promise<Message> {
const channel = await Channel.findOneOrFail({
Expand Down Expand Up @@ -213,6 +213,9 @@ export async function postHandleMessage(message: Message) {
const cachePromises = [];

for (const link of links) {
// Don't embed links in <>
if (link.startsWith("<") && link.endsWith(">")) continue;

const url = new URL(link);

const cached = await EmbedCache.findOne({ where: { url: link } });
Expand Down

0 comments on commit 0ac8888

Please sign in to comment.