diff --git a/packages/frontend/src/pages/search.user.vue b/packages/frontend/src/pages/search.user.vue index d9853e770..596f4da71 100644 --- a/packages/frontend/src/pages/search.user.vue +++ b/packages/frontend/src/pages/search.user.vue @@ -65,6 +65,11 @@ async function search() { return; } + if (query.match(/^@[a-z0-9_.-]+@[a-z0-9_.-]+$/i)) { + router.push(`/${query}`); + return; + } + userPagination.value = { endpoint: 'users/search', limit: 10, diff --git a/packages/frontend/src/widgets/WidgetSearch.vue b/packages/frontend/src/widgets/WidgetSearch.vue index c114707b2..0106df9c4 100644 --- a/packages/frontend/src/widgets/WidgetSearch.vue +++ b/packages/frontend/src/widgets/WidgetSearch.vue @@ -23,6 +23,8 @@ import { i18n } from '@/i18n.js'; import * as os from '@/os.js'; import { useRouter } from '@/router.js'; import { GetFormResultType } from '@/scripts/form.js'; +import { $i } from '@/account.js'; +import { instance } from '@/instance.js'; const name = 'search'; @@ -60,6 +62,7 @@ let notePagination = ref(); let isLocalOnly = ref(false); let order = ref(true); let filetype = ref(null); +const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes)); function options(ev) { os.popupMenu([{ @@ -117,6 +120,19 @@ async function search() { return; } + if (query.match(/^@[a-z0-9_.-]+@[a-z0-9_.-]+$/i)) { + router.push(`/${query}`); + return; + } + + if (!notesSearchAvailable && query.startsWith('#')) { + // can't really search, at least try handling hashtags + router.push(`/tags/${encodeURIComponent(query.substring(1))}`); + return; + } + + // TODO: if !notesSearchAvailable pop up an error message + notePagination.value = { endpoint: 'notes/search', limit: 10,