From 2ce5082018118fafd5cd860b62d692d7da6cc688 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 27 Jan 2024 15:05:35 +0200 Subject: [PATCH] fix: shorter than 6 character invite codes Fixes ZDEV-108 --- backend/src/utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 49a03c27..174a720f 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -557,11 +557,12 @@ export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] { } export function parseInviteCodeInput(str: string): string { - if (str.match(/^[a-z0-9]{6,}$/i)) { - return str; + const parsedInviteCodes = getInviteCodesInString(str); + if (parsedInviteCodes.length) { + return parsedInviteCodes[0]; } - return getInviteCodesInString(str)[0]; + return str; } export function isNotNull(value: T): value is Exclude {