Skip to content

Commit ac5acae

Browse files
committed
test: simplify agent command path joining
1 parent ff4d554 commit ac5acae

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/commands/agent.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,15 @@ vi.mock("../config/sessions/transcript-resolve.runtime.js", () => {
193193
};
194194
const joinPath = (...parts: string[]): string => {
195195
const separator = parts.some((part) => part.includes("\\")) ? "\\" : "/";
196-
return parts
197-
.map((part, index) =>
198-
index === 0 ? part.replace(/[\\/]+$/u, "") : part.replace(/^[\\/]+|[\\/]+$/gu, ""),
199-
)
200-
.filter(Boolean)
201-
.join(separator);
196+
const normalizedParts: string[] = [];
197+
for (const [index, part] of parts.entries()) {
198+
const normalized =
199+
index === 0 ? part.replace(/[\\/]+$/u, "") : part.replace(/^[\\/]+|[\\/]+$/gu, "");
200+
if (normalized.length > 0) {
201+
normalizedParts.push(normalized);
202+
}
203+
}
204+
return normalizedParts.join(separator);
202205
};
203206
const resolveSessionFile = (sessionId: string, agentId: string, sessionsDir?: string): string =>
204207
joinPath(sessionsDir ?? ".openclaw", "agents", agentId, "sessions", `${sessionId}.jsonl`);

0 commit comments

Comments
 (0)