fix(chat): escape command name in regex to prevent unintended matches

This commit is contained in:
Haileyesus
2026-02-12 19:27:57 +03:00
parent ed44d5e437
commit fc1ad17ba8

View File

@@ -25,6 +25,7 @@ import type {
import { useFileMentions } from './useFileMentions';
import { type SlashCommand, useSlashCommands } from './useSlashCommands';
import type { Project, ProjectSession } from '../../../types/app';
import { escapeRegExp } from '../utils/chatFormatting';
type PendingViewSession = {
sessionId: string | null;
@@ -273,7 +274,7 @@ export function useChatComposerState({
}
try {
const commandMatch = input.match(new RegExp(`${command.name}\\s*(.*)`));
const commandMatch = input.match(new RegExp(`${escapeRegExp(command.name)}\\s*(.*)`));
const args =
commandMatch && commandMatch[1] ? commandMatch[1].trim().split(/\s+/) : [];