Skip to content

Commit d0053e9

Browse files
committed
refactor: Remove username validation regex from publicProfile API
- Eliminated the username validation regex to streamline the profile handling process. - Adjusted the username handling logic to focus on required checks without regex validation.
1 parent 534e87f commit d0053e9

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

api/publicProfile.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import User, { USERNAME_COLLATION } from '../models/User.js';
33
import { getLeague } from '../components/utils/leagues.js';
44
import { rateLimit } from '../utils/rateLimit.js';
55

6-
// Username validation regex: alphanumeric and underscores only, 3-20 characters
7-
const USERNAME_REGEX = /^[a-zA-Z0-9_]{3,20}$/;
86

97
// Cache for profile data (userId -> {data, timestamp})
108
const profileCache = new Map();
@@ -60,13 +58,6 @@ export default async function handler(req, res) {
6058
return res.status(400).json({ message: 'Username is required' });
6159
}
6260

63-
// Validate username format (prevent injection attacks)
64-
if (!USERNAME_REGEX.test(username)) {
65-
return res.status(400).json({
66-
message: 'Invalid username format. Username must be 3-20 characters and contain only letters, numbers, and underscores.'
67-
});
68-
}
69-
7061
// Connect to MongoDB if not already connected (needed for view tracking)
7162
if (mongoose.connection.readyState !== 1) {
7263
try {

0 commit comments

Comments
 (0)