From eb966976db269c5c59daf6b2e7c0d8a6a8c7d8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 20 Jan 2023 00:20:56 +0800 Subject: [PATCH] fix: remove protocol from instance uri --- composables/users.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composables/users.ts b/composables/users.ts index 8f466850..0c0e751e 100644 --- a/composables/users.ts +++ b/composables/users.ts @@ -1,3 +1,4 @@ +import { withoutProtocol } from 'ufo' import type { mastodon } from 'masto' import type { EffectScope, Ref } from 'vue' import type { MaybeComputedRef, RemovableRef } from '@vueuse/core' @@ -68,7 +69,7 @@ const publicInstance = ref(null) export const currentInstance = computed(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value) export function getInstanceDomain(instance: ElkInstance) { - return instance.accountDomain || instance.uri + return instance.accountDomain || withoutProtocol(instance.uri) } export const publicServer = ref('') @@ -322,7 +323,7 @@ export function clearUserLocalStorage(account?: mastodon.v1.Account) { if (!account) return - const id = `${account.acct}@${currentInstance.value?.uri || currentServer.value}` + const id = `${account.acct}@${currentInstance.value ? getInstanceDomain(currentInstance.value) : currentServer.value}` // @ts-expect-error bind value to the function const cacheMap = useUserLocalStorage._ as Map | undefined