From e198a34cd0e2cf3bd8c1a78bc1327a8ae69343f1 Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 13 Mar 2023 00:44:38 -0400 Subject: [PATCH] Small fix to Masto ID conversion code --- packages/backend/src/server/api/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index aa65077430..4eb87a6145 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -30,7 +30,7 @@ export enum IdType { export function convertId(idIn: string, idConvertTo: IdType ) { let idArray = [] switch (idConvertTo) { - case IdType.CalckeyId: + case IdType.MastodonId: idArray = [...idIn].map(item => item.charCodeAt(0)); idArray = idArray.map(item => { if (item.toString().length < 3) { @@ -39,8 +39,11 @@ export function convertId(idIn: string, idConvertTo: IdType ) { else return item.toString() }); return idArray.join(''); - case IdType.MastodonId: + case IdType.CalckeyId: for (let i = 0; i < idIn.length; i += 3) { + if ((idIn.length % 3) !== 0) { + idIn = `0${idIn}` + } idArray.push(idIn.slice(i, i+3)); } idArray = idArray.map(item => String.fromCharCode(item));