Preact: Fix format normalization
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled

Fixes #2552
This commit is contained in:
Guangcong Luo 2025-12-05 08:43:33 +00:00
parent a204b277ed
commit be3d1edcae
2 changed files with 12 additions and 2 deletions

View File

@ -1086,6 +1086,17 @@ export class BattleLog {
}
return this.escapeHTML(this.formatName(formatid, fixGen6));
}
static formatId(format: string): ID {
const atIndex = format.indexOf('@@@');
if (atIndex >= 0) {
format = toID(format.slice(0, atIndex)) + format.slice(atIndex).trim();
} else {
format = toID(format);
}
if (!format) return '' as ID;
if (!format.startsWith('gen')) format = `${Dex.modid}${format}`;
return format as ID;
}
/**
* Do not store this output anywhere; it removes the generation number
* for the current gen.

View File

@ -313,8 +313,7 @@ export class ChatRoom extends PSRoom {
format = target;
targetUser = this.pmTarget;
}
format = (format || '').trim();
if (!format.startsWith('gen')) format = `${Dex.modid}${format}`;
format = BattleLog.formatId(format || '');
PS.mainmenu.makeQuery('userdetails', targetUser).then(data => {
if (data.rooms === false) return this.errorReply('This player does not exist or is not online.');
PS.join(`challenge-${toID(targetUser)}` as RoomID, { args: { format } });