Refactoring
This commit is contained in:
14
src/misc/acct.ts
Normal file
14
src/misc/acct.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export type Acct = {
|
||||
username: string;
|
||||
host: string | null;
|
||||
};
|
||||
|
||||
export const getAcct = (user: Acct) => {
|
||||
return user.host == null ? user.username : `${user.username}@${user.host}`;
|
||||
};
|
||||
|
||||
export const parseAcct = (acct: string): Acct => {
|
||||
if (acct.startsWith('@')) acct = acct.substr(1);
|
||||
const split = acct.split('@', 2);
|
||||
return { username: split[0], host: split[1] || null };
|
||||
};
|
@@ -1,7 +0,0 @@
|
||||
import Acct from './type';
|
||||
|
||||
export default (acct: string): Acct => {
|
||||
if (acct.startsWith('@')) acct = acct.substr(1);
|
||||
const split = acct.split('@', 2);
|
||||
return { username: split[0], host: split[1] || null };
|
||||
};
|
@@ -1,5 +0,0 @@
|
||||
import Acct from './type';
|
||||
|
||||
export default (user: Acct) => {
|
||||
return user.host == null ? user.username : `${user.username}@${user.host}`;
|
||||
};
|
@@ -1,6 +0,0 @@
|
||||
type Acct = {
|
||||
username: string;
|
||||
host: string | null;
|
||||
};
|
||||
|
||||
export default Acct;
|
Reference in New Issue
Block a user