diff --git a/backend/test/mastodon/search.spec.ts b/backend/test/mastodon/search.spec.ts index fb2952e..c865b59 100644 --- a/backend/test/mastodon/search.spec.ts +++ b/backend/test/mastodon/search.spec.ts @@ -168,5 +168,12 @@ describe('Mastodon APIs', () => { assert.equal(data.accounts[1].display_name, 'bar') } }) + + test('empty results for invalid handle', async () => { + const db = await makeDB() + const req = new Request('https://example.com/api/v2/search?q= ') + const res = await search.handleRequest(db, req) + assert.equal(res.status, 400) + }) }) }) diff --git a/functions/api/v2/search.ts b/functions/api/v2/search.ts index 408df1a..5fd9081 100644 --- a/functions/api/v2/search.ts +++ b/functions/api/v2/search.ts @@ -7,6 +7,7 @@ import { MastodonAccount } from 'wildebeest/backend/src/types/account' import { parseHandle } from 'wildebeest/backend/src/utils/parse' import { loadExternalMastodonAccount } from 'wildebeest/backend/src/mastodon/account' import { personFromRow } from 'wildebeest/backend/src/activitypub/actors' +import type { Handle } from 'wildebeest/backend/src/utils/parse' const headers = { ...cors(), @@ -38,7 +39,14 @@ export async function handleRequest(db: D1Database, request: Request): Promise