Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api/src/routes/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export const workspaceRoutes: FastifyPluginAsync<WorkspaceRouteOpts> = async (ap
app.get<{ Querystring: { repoRoot?: string } }>('/api/workspace/worktrees', async (request, reply) => {
const { repoRoot } = request.query;
if (repoRoot) {
if (!repoRoot.startsWith('/')) {
if (!isAbsolute(repoRoot)) {
reply.status(400);
return { error: 'repoRoot must be an absolute path' };
}
Expand Down
36 changes: 36 additions & 0 deletions packages/api/test/workspace-windows-path.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import assert from 'node:assert/strict';
import { isAbsolute } from 'node:path';
import { describe, it } from 'node:test';

describe('workspace worktrees repoRoot validation (Windows compat)', () => {
// The route handler uses isAbsolute() to validate repoRoot.
// Previously it used startsWith('/') which rejected Windows paths.

it('accepts Unix absolute path', () => {
assert.ok(isAbsolute('/home/user/project'));
});

it('accepts Windows absolute path with backslash', () => {
assert.ok(isAbsolute('C:\\Personal\\AIProjects\\test-project'));
});

it('accepts Windows absolute path with forward slash', () => {
assert.ok(isAbsolute('C:/Personal/AIProjects/test-project'));
});

it('accepts UNC path', () => {
assert.ok(isAbsolute('\\\\server\\share\\folder'));
});

it('rejects relative path', () => {
assert.ok(!isAbsolute('relative/path'));
});

it('rejects dot-relative path', () => {
assert.ok(!isAbsolute('./src/index.ts'));
});

it('rejects parent-relative path', () => {
assert.ok(!isAbsolute('../etc/passwd'));
});
});
Loading