Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[freecodecamp]: allow + symbol in username #7016

Merged
merged 1 commit into from
Sep 13, 2021
Merged

[freecodecamp]: allow + symbol in username #7016

merged 1 commit into from
Sep 13, 2021

Conversation

SethFalco
Copy link
Contributor

Related

Problem

The pattern I used in the schema instance in freecodecamp-points.service.js was wrong.

I used \w because I thought usernames could only have letters, numbers, hyphens and underscores. I wasn't aware they could have plus until now. Then allowAndStripUnknownKeys kicked off and removed the properties that didn't match the pattern defined, including usernames with a + in it.

Solution

I stole the pattern used to validate usernames from the official freeCodeCamp repository this time, so it should match this time.

const validCharsRE = /^[a-zA-Z0-9\-_+]*$/;

https://github.com/freeCodeCamp/freeCodeCamp/blob/main/utils/validate.js#L14

Now it handles + symbols correctly.

@shields-ci
Copy link

Warnings
⚠️ This PR modified service code for freecodecamp but not its test code.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @SethFalco!

Generated by 🚫 dangerJS against fa747fa

@calebcartwright calebcartwright added the service-badge New or updated service badge label Sep 13, 2021
Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

Was going to say it might be helpful to add a tests for this but I think the comment covers it sufficiently.

Thank you!

@calebcartwright calebcartwright merged commit 13a53f1 into badges:master Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot destructure property 'points' of 'entities.user[username]' as it is undefined.
3 participants