mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix(tools): Handle special characters in file paths for glob and read_many_files (#6507)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -527,6 +527,43 @@ describe('ReadManyFilesTool', () => {
|
||||
expect(truncatedFileContent).toContain('L200');
|
||||
expect(truncatedFileContent).not.toContain('L2400');
|
||||
});
|
||||
|
||||
it('should read files with special characters like [] and () in the path', async () => {
|
||||
const filePath = 'src/app/[test]/(dashboard)/testing/components/code.tsx';
|
||||
createFile(filePath, 'Content of receive-detail');
|
||||
const params = { paths: [filePath] };
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const expectedPath = path.join(tempRootDir, filePath);
|
||||
expect(result.llmContent).toEqual([
|
||||
`--- ${expectedPath} ---
|
||||
|
||||
Content of receive-detail
|
||||
|
||||
`,
|
||||
]);
|
||||
expect(result.returnDisplay).toContain(
|
||||
'Successfully read and concatenated content from **1 file(s)**',
|
||||
);
|
||||
});
|
||||
|
||||
it('should read files with special characters in the name', async () => {
|
||||
createFile('file[1].txt', 'Content of file[1]');
|
||||
const params = { paths: ['file[1].txt'] };
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const expectedPath = path.join(tempRootDir, 'file[1].txt');
|
||||
expect(result.llmContent).toEqual([
|
||||
`--- ${expectedPath} ---
|
||||
|
||||
Content of file[1]
|
||||
|
||||
`,
|
||||
]);
|
||||
expect(result.returnDisplay).toContain(
|
||||
'Successfully read and concatenated content from **1 file(s)**',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Batch Processing', () => {
|
||||
|
||||
Reference in New Issue
Block a user