utils/accounts: pick only needed fields from type
This commit is contained in:
parent
060a9b559d
commit
8a4239d153
1 changed files with 2 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
import type { Account } from 'soapbox/schemas';
|
import type { Account } from 'soapbox/schemas';
|
||||||
import type { Account as AccountEntity } from 'soapbox/types/entities';
|
import type { Account as AccountEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
const getDomainFromURL = (account: AccountEntity): string => {
|
const getDomainFromURL = (account: Pick<AccountEntity, 'url'>): string => {
|
||||||
try {
|
try {
|
||||||
const url = account.url;
|
const url = account.url;
|
||||||
return new URL(url).host;
|
return new URL(url).host;
|
||||||
|
@ -10,7 +10,7 @@ const getDomainFromURL = (account: AccountEntity): string => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDomain = (account: AccountEntity): string => {
|
export const getDomain = (account: Pick<AccountEntity, 'acct' | 'url'>): string => {
|
||||||
const domain = account.acct.split('@')[1];
|
const domain = account.acct.split('@')[1];
|
||||||
return domain ? domain : getDomainFromURL(account);
|
return domain ? domain : getDomainFromURL(account);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue