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:
parent
8914fe83c4
commit
846e623e3e
6 changed files with 888 additions and 5 deletions
|
@ -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}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue