mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
fix(policy): remove unnecessary escapeRegex from pattern builders
- Removed escapeRegex wrapping in buildFilePathArgsPattern and buildPatternArgsPattern as per review comments. - Removed the comment documenting the previous implementation in buildFilePathArgsPattern. - Confirmed autoAddToPolicyByDefault is already set to false.
This commit is contained in:
@@ -97,11 +97,8 @@ export function buildArgsPatterns(
|
||||
* @returns A regex string that matches "file_path":"<path>" in a JSON string.
|
||||
*/
|
||||
export function buildFilePathArgsPattern(filePath: string): string {
|
||||
// JSON.stringify safely encodes the path (handling quotes, backslashes, etc)
|
||||
// and wraps it in double quotes. We simply prepend the key name and escape
|
||||
// the entire sequence for Regex matching without any slicing.
|
||||
const encodedPath = JSON.stringify(filePath);
|
||||
return escapeRegex(`"file_path":${encodedPath}`);
|
||||
return `"file_path":${encodedPath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,5 +110,5 @@ export function buildFilePathArgsPattern(filePath: string): string {
|
||||
*/
|
||||
export function buildPatternArgsPattern(pattern: string): string {
|
||||
const encodedPattern = JSON.stringify(pattern);
|
||||
return escapeRegex(`"pattern":${encodedPattern}`);
|
||||
return `"pattern":${encodedPattern}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user