This commit is contained in:
dahyeon committed 2026-05-02 05:23:56 -07:00
1 parent bd3cd4fa5f
commit a5654c02a2
6 files changed
+327 -62

No files matched your search

@@ -10,9 +10,7 @@ export type DakaoCommand =
}
| {
kind: 'match-join';
matchId: string;
gameName: string;
tagLine: string;
matchAndRiotId: string;
positions: ParsedPositions;
}
| {
@@ -111,38 +109,22 @@ function parseJoinArgs(args: string): DakaoCommand {
throw new CommandParseError('usage');
}
// 마지막 토큰이 포지션 리스트(쉼표 포함). 그 앞이 라이엇 ID(공백 포함 가능). 그 앞이 matchId.
// 형식: <matchId> <gameName...>#<tagLine> <pos1>,<pos2>...
// 마지막 토큰이 포지션 리스트(쉼표 포함). 그 앞은 내전 식별자(선택)와 라이엇 ID.
// 형식: [<matchId|title...>] <gameName...>#<tagLine> <pos1>,<pos2>...
// 끝에서부터 토큰을 분리해 안정적으로 파싱한다.
const lastSpace = args.lastIndexOf(' ');
if (lastSpace === -1) {
throw new CommandParseError('usage');
}
const positionPart = args.slice(lastSpace + 1).trim();
const head = args.slice(0, lastSpace).trim();
if (positionPart.length === 0 || head.length === 0) {
const matchAndRiotId = args.slice(0, lastSpace).trim();
if (positionPart.length === 0 || matchAndRiotId.length === 0) {
throw new CommandParseError('usage');
}
const headSpace = head.indexOf(' ');
if (headSpace === -1) {
throw new CommandParseError('usage');
}
const matchId = head.slice(0, headSpace).trim();
const riotId = head.slice(headSpace + 1).trim();
if (!isObjectIdHex(matchId)) {
throw new CommandParseError('invalid_match_id', matchId);
}
const hashIndex = riotId.lastIndexOf('#');
if (hashIndex <= 0 || hashIndex === riotId.length - 1) {
throw new CommandParseError('invalid_riot_id', riotId);
}
const gameName = normalizeRiotIdPart(riotId.slice(0, hashIndex));
const tagLine = normalizeRiotIdPart(riotId.slice(hashIndex + 1));
if (gameName.length === 0 || tagLine.length === 0) {
throw new CommandParseError('invalid_riot_id', riotId);
const hashIndex = matchAndRiotId.lastIndexOf('#');
if (hashIndex <= 0 || hashIndex === matchAndRiotId.length - 1) {
throw new CommandParseError('invalid_riot_id', matchAndRiotId);
}
let positions: ParsedPositions;
@@ -157,9 +139,7 @@ function parseJoinArgs(args: string): DakaoCommand {
return {
kind: 'match-join',
matchId,
gameName,
tagLine,
matchAndRiotId,
positions,
};
}