3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-18 15:45:03 +00:00

Initial work on new automod

This commit is contained in:
Dragory 2019-08-18 16:40:15 +03:00
parent 8914fe83c4
commit 846e623e3e
6 changed files with 888 additions and 5 deletions

View file

@ -175,8 +175,10 @@ export async function findRelevantAuditLogEntry(
const urlRegex = /(\S+\.\S+)/g;
const protocolRegex = /^[a-z]+:\/\//;
export function getUrlsInString(str: string): url.URL[] {
const matches = str.match(urlRegex) || [];
export function getUrlsInString(str: string, unique = false): url.URL[] {
let matches = str.match(urlRegex).map(m => m[0]) || [];
if (unique) matches = Array.from(new Set(matches));
return matches.reduce((urls, match) => {
if (!protocolRegex.test(match)) {
match = `https://${match}`;