From 5fcfebe55c952773e3923558571919c76cad1116 Mon Sep 17 00:00:00 2001 From: shnimlz Date: Sat, 11 Oct 2025 16:34:18 -0500 Subject: [PATCH] =?UTF-8?q?Elimina=20la=20l=C3=B3gica=20de=20validaci?= =?UTF-8?q?=C3=B3n=20de=20URLs=20en=20la=20funci=C3=B3n=20'extractValidLin?= =?UTF-8?q?ks'=20para=20simplificar=20el=20manejo=20de=20enlaces=20y=20opt?= =?UTF-8?q?imizar=20el=20rendimiento.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/extras/alliace.ts | 45 +++--------------------------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/src/events/extras/alliace.ts b/src/events/extras/alliace.ts index 2668f14..fa801c9 100644 --- a/src/events/extras/alliace.ts +++ b/src/events/extras/alliace.ts @@ -74,48 +74,9 @@ export async function alliance(message: Message) { function extractValidLinks(content: string): string[] { const matches = content.match(URL_REGEX); - if (!matches) return []; - - const results: string[] = []; - for (const raw of matches) { - try { - const url = new URL(raw); - - // Sólo http/https - if (url.protocol !== "http:" && url.protocol !== "https:") continue; - - // Rechazar URLs con query string o fragment (ej: ?event=...) - if (url.search || url.hash) continue; - - // Normalizar hostname y pathname - const host = url.hostname.toLowerCase(); - const pathname = url.pathname.replace(/\/+/g, "/"); - - // Validar formatos de invitación de Discord estrictos - if (host === "discord.gg") { - // debe ser / - if (!/^\/[A-Za-z0-9]+$/.test(pathname)) continue; - } else if ( - host === "discord.com" || - host === "www.discord.com" || - host === "discordapp.com" || - host === "www.discordapp.com" - ) { - // debe ser /invite/ - if (!/^\/invite\/[A-Za-z0-9]+$/.test(pathname)) continue; - } - - // Si llegó hasta aquí, es aceptable - results.push(url.toString()); - } catch { - // ignorar coincidencias inválidas - continue; - } - } - - return results; + return matches || []; } -// ...existing code... + function validateDiscordLinks(links: string[]): string[] { return links.filter((link) => { return DISCORD_DOMAINS.some((domain) => link.includes(domain)); @@ -600,7 +561,7 @@ async function processConfigVariables( } if (Array.isArray(config)) { - const processedArray: any[] = []; + const processedArray = []; for (const item of config) { // @ts-ignore processedArray.push(