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));