Files
wehub-resource-sync e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

18 lines
573 B
TypeScript

/**
* Case-insensitive username filter backing the admin Users search box.
* An empty / whitespace-only query returns the input list unchanged.
*
* Generic over `{ username }` (rather than importing UserRecord) so the
* module stays alias-free and loadable by the node unit tests.
*/
export function filterUsersByQuery<T extends { username: string }>(
users: T[],
query: string,
): T[] {
const normalized = query.trim().toLowerCase();
if (!normalized) return users;
return users.filter((user) =>
user.username.toLowerCase().includes(normalized),
);
}