diff --git a/src/web/routes/file-routes.ts b/src/web/routes/file-routes.ts index 4e7a886e..ba521cd0 100644 --- a/src/web/routes/file-routes.ts +++ b/src/web/routes/file-routes.ts @@ -2404,7 +2404,8 @@ export function registerFileRoutes(app: FastifyInstance, ctx: SessionPort & Even reply.code(400).send(createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Missing folder path')); return; } - if (scope.docker && body.path.startsWith('~/')) { + // A bare `~` expands to this host's home too, not the container's. + if (scope.docker && (body.path === '~' || body.path.startsWith('~/'))) { reply.code(400).send(createErrorResponse(ApiErrorCode.INVALID_INPUT, DOCKER_HOME_PATH_ERROR)); return; } diff --git a/test/routes/folder-grid-routes.test.ts b/test/routes/folder-grid-routes.test.ts index e2575f5c..fee03639 100644 --- a/test/routes/folder-grid-routes.test.ts +++ b/test/routes/folder-grid-routes.test.ts @@ -341,6 +341,8 @@ describe('folder grid routes — local folder', () => { const home = await grant('~/renders'); expect(home.statusCode).toBe(400); expect(JSON.parse(home.body).error).toMatch(/docker/i); + // A bare `~` is this host's home as much as `~/` is. + expect((await grant('~')).statusCode).toBe(400); expect((await grant(dir)).statusCode).toBe(200); });