Fix IGN special characters not counting correctly for word limit
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run

This commit is contained in:
Kalle
2026-03-09 20:42:45 +02:00
parent c5095f4074
commit 6834c86952
4 changed files with 10 additions and 3 deletions

View File

@@ -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)),

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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",