Skip to content

Commit 270659a

Browse files
committed
Protocol in the links is optional, prevent links with or without protocol
1 parent d1e77cf commit 270659a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/telegramBot/bridge/service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const { bridgedMessagesCounter } = require("../../promMetrics/promCounters");
1212

1313
// github copilot generated function to prevent telegram & discord links
1414
const isMessageSafeToSend = (message) => {
15-
const telegramLinkPattern = /https?:\/\/(www\.)?t(elegram)?\.me\/[a-zA-Z0-9\-_]*/g;
16-
const discordLinkPattern = /https?:\/\/(www\.)?discord\.gg\/[a-zA-Z0-9\-_]*/g;
15+
const telegramLinkPattern = /(https?:\/\/)?(www\.)?t(elegram)?\.me\/[a-zA-Z0-9\-_]*/g;
16+
const discordLinkPattern = /(https?:\/\/)?(www\.)?discord\.gg\/[a-zA-Z0-9\-_]*/g;
1717

1818
if (telegramLinkPattern.test(message) || discordLinkPattern.test(message)) {
1919
return false;

0 commit comments

Comments
 (0)