From 7760d03f9df1cc25335311e031b2f34e578eac79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sun, 4 Dec 2022 15:18:11 +0800 Subject: [PATCH] fix: get server name from acct --- composables/masto.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/composables/masto.ts b/composables/masto.ts index a4a1fb77..0824b14d 100644 --- a/composables/masto.ts +++ b/composables/masto.ts @@ -28,10 +28,6 @@ export const STATUS_VISIBILITIES = [ }, ] as const -export function getServerName(account: Account) { - return account.url.match(UserLinkRE)?.[1] || currentUser.value?.server || '' -} - export function getDisplayName(account?: Account, options?: { rich?: boolean }) { const displayName = account?.displayName || account?.username || '' if (options?.rich) @@ -45,6 +41,12 @@ export function getShortHandle({ acct }: Account) { return `@${acct.includes('@') ? acct.split('@')[0] : acct}` } +export function getServerName(account: Account) { + if (account.acct.includes('@')) + return account.acct.split('@')[1] + return account.url.match(UserLinkRE)?.[1] || currentUser.value?.server || '' +} + export function getFullHandle(account: Account) { const handle = `@${account.acct}` if (!currentUser.value || account.acct.includes('@'))