fix(federation): 🐛 Correctly handle non-lowercase acct queries in account lookups

This commit is contained in:
Jesse Wierzbinski 2024-11-24 17:42:30 +01:00
parent 259fba17a7
commit 340ed7b258
No known key found for this signature in database
2 changed files with 25 additions and 1 deletions

View file

@ -34,4 +34,28 @@ describe(meta.route, () => {
}), }),
); );
}); });
test("should automatically lowercase the acct", async () => {
const response = await fakeRequest(
`${meta.route}?acct=${users[0].data.username.toUpperCase()}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
},
},
);
expect(response.status).toBe(200);
const data = (await response.json()) as ApiAccount[];
expect(data).toEqual(
expect.objectContaining({
id: users[0].id,
username: users[0].data.username,
display_name: users[0].data.displayName,
avatar: expect.any(String),
header: expect.any(String),
}),
);
});
}); });

View file

@ -23,7 +23,7 @@ export const meta = applyConfig({
export const schemas = { export const schemas = {
query: z.object({ query: z.object({
acct: z.string().min(1).max(512), acct: z.string().min(1).max(512).toLowerCase(),
}), }),
}; };