From 48adb1df90dea92b0f1f1c6290b82e77ec525274 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 30 Nov 2019 22:05:48 +0200 Subject: [PATCH] chore: clean up getInviteCodesInString --- backend/src/utils.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 2005f862..139f9d18 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -345,15 +345,7 @@ export function getUrlsInString(str: string, unique = false): url.URL[] { export function getInviteCodesInString(str: string): string[] { const inviteCodeRegex = /(?:discord.gg|discordapp.com\/invite)\/([a-z0-9]+)/gi; - const inviteCodes = []; - let match; - - // tslint:disable-next-line - while ((match = inviteCodeRegex.exec(str)) !== null) { - inviteCodes.push(match[1]); - } - - return inviteCodes; + return Array.from(str.matchAll(inviteCodeRegex)).map(m => m[1]); } export const unicodeEmojiRegex = emojiRegex();