From 7ed94e94d1ae7f23396328547ed4a9cb5a9dbd48 Mon Sep 17 00:00:00 2001 From: weishu Date: Wed, 17 Dec 2025 19:55:12 +0800 Subject: [PATCH] fix: include underscore in path normalization regex --- src/claude/utils/path.test.ts | 8 +++++++- src/claude/utils/path.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/claude/utils/path.test.ts b/src/claude/utils/path.test.ts index 3e0e594c..25c73e4e 100644 --- a/src/claude/utils/path.test.ts +++ b/src/claude/utils/path.test.ts @@ -38,6 +38,12 @@ describe('getProjectPath', () => { expect(result).toBe(join('/home/user', '.claude', 'projects', '-var-www-my-site-com-public')); }); + it('should replace underscores with hyphens in the project path', () => { + const workingDir = '/var/www/test__underscore'; + const result = getProjectPath(workingDir); + expect(result).toBe(join('/home/user', '.claude', 'projects', '-var-www-test--underscore')); + }); + it('should handle relative paths by resolving them first', () => { const workingDir = './my-project'; const result = getProjectPath(workingDir); @@ -86,4 +92,4 @@ describe('getProjectPath', () => { expect(result).toBe(join('/custom/claude/config/', 'projects', '-Users-steve-projects-my-app')); }); }); -}); \ No newline at end of file +}); diff --git a/src/claude/utils/path.ts b/src/claude/utils/path.ts index 39a638af..5580e3b1 100644 --- a/src/claude/utils/path.ts +++ b/src/claude/utils/path.ts @@ -2,7 +2,7 @@ import { homedir } from "node:os"; import { join, resolve } from "node:path"; export function getProjectPath(workingDirectory: string) { - const projectId = resolve(workingDirectory).replace(/[\\\/\.:]/g, '-'); + const projectId = resolve(workingDirectory).replace(/[\\\/\.:_]/g, '-'); const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude'); return join(claudeConfigDir, 'projects', projectId); } \ No newline at end of file