mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix: handle underscores in project path generation
Add underscore to the regex pattern in getProjectPath to ensure underscores are replaced with hyphens, along with existing handling for slashes, colons, and dots. Includes test case for paths with underscores.
This commit is contained in:
@@ -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 = '/data/github/hapi__worktrees/ime';
|
||||
const result = getProjectPath(workingDir);
|
||||
expect(result).toBe(join('/home/user', '.claude', 'projects', '-data-github-hapi--worktrees-ime'));
|
||||
});
|
||||
|
||||
it('should handle relative paths by resolving them first', () => {
|
||||
const workingDir = './my-project';
|
||||
const result = getProjectPath(workingDir);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user