Skip to content

fix: normalize quiz join inputs - #166

Open
QvarcY wants to merge 1 commit into
TheCodeHeist-Coder:mainfrom
QvarcY:fix/join-whitespace
Open

QvarcY wants to merge 1 commit into
TheCodeHeist-Coder:mainfrom
QvarcY:fix/join-whitespace

Conversation

@QvarcY

@QvarcY QvarcY commented Sep 26, 2026

Copy link
Copy Markdown

Summary

Fixes #159.

The quiz join form now normalizes participant input before it is submitted:

  • strips whitespace and other non-alphanumeric characters from pasted game PINs
  • uppercases the PIN and applies the six-character limit after normalization
  • trims nicknames on submit without preventing spaces inside names while typing
  • rejects whitespace-only nicknames with a clear message
  • uses the normalized nickname consistently for the API request, localStorage and navigation state
  • adds regression coverage for pasted PINs and whitespace-only nicknames

Why

Previously the browser's maxLength={6} could count pasted whitespace toward the PIN length before the value was normalized. A valid copied code could therefore be truncated and produce a misleading "Quiz not found" error.

Nicknames were also submitted without trimming, and a whitespace-only nickname passed the existing truthiness check.

Verification

  • targeted JoinQuiz tests: 2/2 passed
  • full frontend test suite: 27/27 passed
  • changed files pass ESLint
  • frontend production build passes
  • git diff --check passes

Existing lint baseline

The repository-wide frontend lint already fails on unrelated files in current main.

Before this change:

  • 20 errors
  • 2 warnings

After this change:

  • 19 errors
  • 2 warnings

The reduction comes from removing the existing any in JoinQuiz.tsx. Both files changed by this PR are lint-clean.

@TheCodeHeist-Coder

Copy link
Copy Markdown
Owner

Awesome work! 🔥
Thanks for taking up the issue and fixing it. This is a great first contribution to the project — really appreciate it!

Welcome aboard, and looking forward to more contributions from you.

@TheCodeHeist-Coder TheCodeHeist-Coder left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It's a clean and as expected code

This branch has not been deployed

No deployments
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.

[Bug]: A pasted join code with a trailing space fails with "Quiz not found"

2 participants