fix(frontend): default empty path/cwd to root dot in fs_glob and fs_tree
This commit is contained in:
@@ -5144,7 +5144,11 @@ async function toolFsGlob(principal: Principal, params: Record<string, any>) {
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const cwd = normalizeFsPath(String(params.cwd ?? ""), project.slug);
|
||||
const rawCwd =
|
||||
params.cwd === undefined || params.cwd === null || params.cwd === ""
|
||||
? "."
|
||||
: String(params.cwd);
|
||||
const cwd = normalizeFsPath(rawCwd, project.slug);
|
||||
if (cwd instanceof NextResponse) return cwd;
|
||||
// ripgrep --files --glob is faster + smarter than `find` and respects .gitignore.
|
||||
const cmd = `cd ${shq(cwd)} && rg --files --glob ${shq(pattern)} | head -500`;
|
||||
@@ -6261,7 +6265,11 @@ async function toolFsTree(principal: Principal, params: Record<string, any>) {
|
||||
if (guard) return guard;
|
||||
const project = await resolveProjectOr404(principal, params);
|
||||
if (project instanceof NextResponse) return project;
|
||||
const path = normalizeFsPath(String(params.path ?? ""), project.slug);
|
||||
const rawPath =
|
||||
params.path === undefined || params.path === null || params.path === ""
|
||||
? "."
|
||||
: String(params.path);
|
||||
const path = normalizeFsPath(rawPath, project.slug);
|
||||
if (path instanceof NextResponse) return path;
|
||||
|
||||
// Use find to generate a tree structure, ignoring node_modules and .git
|
||||
|
||||
Reference in New Issue
Block a user