Skip to content

Commit

Permalink
properly prevent spamming the api
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Oct 22, 2024
1 parent bf8bb1a commit 14c236a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/userLookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ export const LookupMenu: React.FC<LookupMenuProps> = (
updateUser({ userCkey: value });
return;
}
if (
potentialUser &&
(!userData || userData.ckey != potentialUser.toLowerCase())
) {

if (!potentialUser) return;

const re = /[\\^]|[^a-z0-9@]/g;
const checked = potentialUser.toLowerCase().replace(re, "");

if (potentialUser && (!userData || userData.ckey != checked)) {
updateUser({ userCkey: potentialUser as string });
}
}, [value, userData, discordId, updateUser, potentialUser, user, loading]);
Expand Down

0 comments on commit 14c236a

Please sign in to comment.