Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/constants/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export const GENERATE_USERNAME_URL = (
sanitizedFirstname,
sanitizedLastname,
) => {
return `${APPS.API_BACKEND}/users/username?dev=true&firstname=${sanitizedFirstname}&lastname=${sanitizedLastname}`;
return `${APPS.API_BACKEND}/users/username?dev=true&firstname=${encodeURIComponent(sanitizedFirstname)}&lastname=${encodeURIComponent(sanitizedLastname)}`;
};

export const CHECK_USERNAME_AVAILABILITY = (userName) => {
return `${APPS.API_BACKEND}/users/isUsernameAvailable/${userName}`;
return `${APPS.API_BACKEND}/users/isUsernameAvailable/${encodeURIComponent(userName)}`;
};
Comment on lines 28 to 30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Path-segment encoding is correct, but verify backend decoding + routing expectations.
encodeURIComponent(userName) will encode / as %2F (treating username as opaque), which is typically desirable, but please confirm the backend route /users/isUsernameAvailable/:userName (and any proxies) reliably decode this and don’t expect raw slashes.

Optional: if you want to avoid path-segment edge cases entirely, consider switching this endpoint to a query param (.../isUsernameAvailable?userName=...) if the backend supports it.


export const SELF_USERS_URL = `${APPS.API_BACKEND}/users/self`;
Expand Down