From e89f56a97e6ec77ef77a9d5eda7d4b79438b2859 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Wed, 17 Jul 2024 01:34:21 +0200 Subject: [PATCH] fix: :bug: Make usernames case-insensitive when searching and viewing profiles --- pages/[username]/index.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pages/[username]/index.vue b/pages/[username]/index.vue index 6ad22e6..0cc50c8 100644 --- a/pages/[username]/index.vue +++ b/pages/[username]/index.vue @@ -22,12 +22,19 @@ definePageMeta({ const route = useRoute(); const client = useClient(); -const username = (route.params.username as string).replace("@", ""); +const username = (route.params.username as string).startsWith("@") + ? (route.params.username as string).substring(1) + : (route.params.username as string); const accounts = useAccountSearch(client, username); watch(accounts, (newValue) => { if (Array.isArray(newValue)) { - if (!newValue.find((account) => account.acct === username)) { + if ( + !newValue.find( + (account) => + account.acct.toLowerCase() === username.toLowerCase(), + ) + ) { useEvent("error", { title: "Account not found", message: `The account @${username} does not exist.`, @@ -37,7 +44,10 @@ watch(accounts, (newValue) => { } }); const account = computed( - () => accounts.value?.find((account) => account.acct === username) ?? null, + () => + accounts.value?.find( + (account) => account.acct.toLowerCase() === username.toLowerCase(), + ) ?? null, ); const accountId = computed(() => account.value?.id ?? undefined);