1
0
mirror of https://github.com/hotomoe/hotomoe synced 2025-01-17 15:22:51 +09:00
hotomoe/src/misc/acct.ts

12 lines
373 B
TypeScript
Raw Normal View History

import * as Misskey from 'misskey-js';
2021-07-15 20:45:32 +09:00
export const getAcct = (user: Misskey.Acct) => {
2021-07-15 20:45:32 +09:00
return user.host == null ? user.username : `${user.username}@${user.host}`;
};
export const parseAcct = (acct: string): Misskey.Acct => {
2021-07-15 20:45:32 +09:00
if (acct.startsWith('@')) acct = acct.substr(1);
const split = acct.split('@', 2);
return { username: split[0], host: split[1] || null };
};