From a87201b888fc0accc7836aaaf8c9c569462bbaad Mon Sep 17 00:00:00 2001 From: dumbfox Date: Sat, 8 Jul 2023 08:26:46 +0000 Subject: [PATCH] fix(backend): search user with trailing space --- packages/backend/src/server/api/endpoints/users/search.ts | 2 ++ packages/backend/src/server/api/endpoints/users/show.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index 177441bc78ba..219fbc552d9e 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -6,6 +6,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { DI } from '@/di-symbols.js'; import { sqlLikeEscape } from '@/misc/sql-like-escape.js'; +import { query } from '@/misc/prelude/url.js'; export const meta = { tags: ['users'], @@ -52,6 +53,7 @@ export default class extends Endpoint { super(meta, paramDef, async (ps, me) => { const activeThreshold = new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)); // 30日 + ps.query = ps.query.trim(); const isUsername = ps.query.startsWith('@'); let users: User[] = []; diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts index ba432c273bfb..8e25af64fec5 100644 --- a/packages/backend/src/server/api/endpoints/users/show.ts +++ b/packages/backend/src/server/api/endpoints/users/show.ts @@ -91,6 +91,7 @@ export default class extends Endpoint { let user; const isModerator = await this.roleService.isModerator(me); + ps.username = ps.username?.trim(); if (ps.userIds) { if (ps.userIds.length === 0) {