mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 07:12:36 -05:00
Fix IGN special characters not counting correctly for word limit
This commit is contained in:
@@ -163,7 +163,9 @@ export const adminActionSchema = z.union([
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_IN_GAME_NAME"),
|
||||
inGameNameText: z.string().max(USER.IN_GAME_NAME_TEXT_MAX_LENGTH),
|
||||
inGameNameText: z
|
||||
.string()
|
||||
.refine((val) => [...val].length <= USER.IN_GAME_NAME_TEXT_MAX_LENGTH),
|
||||
inGameNameDiscriminator: z
|
||||
.string()
|
||||
.refine((val) => /^[0-9a-z]{4,5}$/.test(val)),
|
||||
|
||||
@@ -10,6 +10,7 @@ describe("IN_GAME_NAME_REGEXP", () => {
|
||||
"A#1234",
|
||||
"Player#abcd",
|
||||
"名前テスト1234#ab12c",
|
||||
"☆CR☆Sh𝓔𝓔p!#1234",
|
||||
];
|
||||
|
||||
for (const name of validNames) {
|
||||
@@ -28,6 +29,7 @@ describe("IN_GAME_NAME_REGEXP", () => {
|
||||
"Sendou#123456",
|
||||
"Sendou#ABCD",
|
||||
"12345678901#1234",
|
||||
"𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔#1234",
|
||||
];
|
||||
|
||||
for (const name of invalidNames) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export const USER = {
|
||||
GAME_BADGES_SMALL_MAX: 4,
|
||||
};
|
||||
|
||||
export const IN_GAME_NAME_REGEXP = /^.{1,10}#[0-9a-z]{4,5}$/;
|
||||
export const IN_GAME_NAME_REGEXP = /^.{1,10}#[0-9a-z]{4,5}$/u;
|
||||
|
||||
export const MATCHES_PER_SEASONS_PAGE = 8;
|
||||
export const RESULTS_PER_PAGE = 25;
|
||||
|
||||
@@ -101,7 +101,10 @@ export const userEditProfileBaseSchema = z.object({
|
||||
inGameName: textFieldOptional({
|
||||
label: "labels.profileInGameName",
|
||||
bottomText: "bottomTexts.profileInGameName",
|
||||
maxLength: 10 + 1 + 5, // 10 for name, 1 for #, 5 for discriminator
|
||||
maxLength:
|
||||
USER.IN_GAME_NAME_TEXT_MAX_LENGTH +
|
||||
1 +
|
||||
USER.IN_GAME_NAME_DISCRIMINATOR_MAX_LENGTH,
|
||||
regExp: {
|
||||
pattern: IN_GAME_NAME_REGEXP,
|
||||
message: "forms:errors.profileInGameName",
|
||||
|
||||
Reference in New Issue
Block a user