-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: displayName regex #6138
fix: displayName regex #6138
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that browsers are a bit picky and each one them have their on wierdness so I've tried my best to find the right solution. I've left a comment about my findings.
src/storage/store.js
Outdated
displayName: { type: "string", pattern: "^(?:[A-Z]|[a-z]|[0-9]|[_~\\-]|\\s){3,32}$" }, | ||
avatarId: { type: "string" }, | ||
pronouns: { type: "string", pattern: "^[a-zA-Z///a-zA-Z]{2,32}$" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to still make Chrome complain. After some testing this seems not to raise any complaints in both Chrome & Firefox:
displayName: { type: "string", pattern: "^[A-Za-z0-9_~\\s\\-]{3,32}$" },
avatarId: { type: "string" },
pronouns: { type: "string", pattern: "^([a-zA-Z]{1,32}\\/){0,4}[a-zA-Z]{1,32}$" },
This pronouns regex is a bit more strict and enforces the A/B form and you can have up to 5 pronouns that I think it's probably enough for what I've seen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we prefer to keep the previous regex format, this would work:
^[a-zA-Z\\/a-zA-Z]{2,32}$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! Thanks for looking into alternatives. I'll update the pronouns with your suggestion - its currently had a few incarnations (enforcing one '/', and leaving it out as an option) but I like your suggestion that allows for up to 5 pronouns. 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
Solves this console error:
Pattern attribute value ^[A-Za-z0-9_~ -]{3,32}$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^[A-Za-z0-9_~ -]{3,32}$/v: Invalid character in character class