Skip to content

Conversation

@Rehankhan009
Copy link

Date: 12/12/2025

Developer Name: Mohammad Rehan Khan


Issue Ticket Number:-

  • #1105

Description:

✅ LastName with spaces (e.g., "A M") now works correctly
✅ FirstName with spaces also handled properly
✅ Special characters in names are properly encoded
✅ Username generation API calls succeed with properly formatted URLs
✅ Username availability checks handle special characters correctly

The fix ensures that any special characters (spaces, apostrophes, accented characters, etc.) in names are properly URL-encoded, preventing malformed API requests and allowing the signup flow to complete successfully.

Is Under Feature Flag

  • Yes
  • No

Database changes

  • Yes
  • No

Breaking changes (If your feature is breaking/missing something please mention pending tickets)

  • Yes
  • No

Is Development Tested?

  • Yes
  • No

Tested in staging?

  • Yes
  • No

@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Fixed URL encoding for username generation and availability checks to properly handle special characters and prevent potential errors.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Updates URL construction in the APIs constants file to properly encode query parameters using encodeURIComponent. The changes affect username generation and availability check endpoints, ensuring special characters in user names are safely transmitted via URLs while maintaining all existing function signatures and exports.

Changes

Cohort / File(s) Change Summary
URL Parameter Encoding
app/constants/apis.js
GENERATE_USERNAME_URL now encodes sanitizedFirstname and sanitizedLastname with encodeURIComponent; CHECK_USERNAME_AVAILABILITY now encodes userName with encodeURIComponent. Function signatures and other exports (SELF_USERS_URL, etc.) remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

  • Single file modification with straightforward parameter encoding additions
  • No changes to function signatures, exports, or control flow logic
  • Minimal risk; encoding is standard practice for URL parameters
  • Verify that all user-facing name inputs are covered by the encoding

Poem

A rabbit hops through URLs so fine, 🐰
With special chars now in a line,
EncodeURIComponent's the way,
To keep those query strings at bay,
Safe travels now, both day and night!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: last name with space issue' directly corresponds to the main change in the PR, which addresses URL encoding of names (including last names with spaces) in API calls.
Description check ✅ Passed The description is directly related to the changeset, detailing the fix for handling special characters in names through URL encoding, which matches the code changes in the raw summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/constants/apis.js (1)

21-26: Good fix: query params are now correctly URL-encoded (prevents spaces/special chars breaking the request).
This aligns with the PR objective; encoding firstname/lastname in the query string is the right move.

Hardening suggestion: consider guarding nullish/non-string inputs to avoid accidental "undefined"/"null" being sent if upstream sanitization regresses.

 export const GENERATE_USERNAME_URL = (
   sanitizedFirstname,
   sanitizedLastname,
 ) => {
-  return `${APPS.API_BACKEND}/users/username?dev=true&firstname=${encodeURIComponent(sanitizedFirstname)}&lastname=${encodeURIComponent(sanitizedLastname)}`;
+  const firstname = encodeURIComponent(String(sanitizedFirstname ?? ''));
+  const lastname = encodeURIComponent(String(sanitizedLastname ?? ''));
+  return `${APPS.API_BACKEND}/users/username?dev=true&firstname=${firstname}&lastname=${lastname}`;
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f0b914 and b7de46f.

📒 Files selected for processing (1)
  • app/constants/apis.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/constants/apis.js (1)
app/constants/urls.js (2)
  • APPS (65-65)
  • APPS (65-65)

Comment on lines 28 to 30
export const CHECK_USERNAME_AVAILABILITY = (userName) => {
return `${APPS.API_BACKEND}/users/isUsernameAvailable/${userName}`;
return `${APPS.API_BACKEND}/users/isUsernameAvailable/${encodeURIComponent(userName)}`;
};
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant