From b682448c9541192931240ae927e66ae25df3022d Mon Sep 17 00:00:00 2001 From: skeletor Date: Fri, 18 Mar 2022 05:01:25 +0000 Subject: [PATCH] fix image generation when part position is omitted --- src/nitro/session/badge/BadgeImageManager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nitro/session/badge/BadgeImageManager.ts b/src/nitro/session/badge/BadgeImageManager.ts index 387a7243..757c7a97 100644 --- a/src/nitro/session/badge/BadgeImageManager.ts +++ b/src/nitro/session/badge/BadgeImageManager.ts @@ -168,7 +168,7 @@ export class BadgeImageManager implements IDisposable private loadGroupBadge(badgeCode: string): void { const groupBadge = new GroupBadge(badgeCode); - const partMatches = [...badgeCode.matchAll(/[b|s][0-9]{5,6}/g)]; + const partMatches = [...badgeCode.matchAll(/[b|s][0-9]{4,6}/g)]; for(const partMatch of partMatches) { @@ -177,7 +177,7 @@ export class BadgeImageManager implements IDisposable const partType = partCode[0]; const partId = parseInt(partCode.slice(1, shortMethod ? 3 : 4)); const partColor = parseInt(partCode.slice(shortMethod ? 3 : 4, shortMethod ? 5 : 6)); - const partPosition = parseInt(partCode.slice(shortMethod ? 5 : 6, shortMethod ? 6 : 7)); + const partPosition = partCode.length < 6 ? 0 : parseInt(partCode.slice(shortMethod ? 5 : 6, shortMethod ? 6 : 7)); // sometimes position is ommitted const part = new GroupBadgePart(partType, partId, partColor, partPosition); groupBadge.parts.push(part);