fix(hooks): correct cross-platform path handling in getProjectSettingsPath

Remove incorrect path separator conversion that caused directory creation
issues on Linux/WSL platforms. The function was converting forward slashes
to backslashes, which are treated as literal filename characters on Unix
systems rather than path separators.

Changes:
- Remove manual path normalization in getProjectSettingsPath()
- Rely on Node.js path.join() for cross-platform compatibility
- Fix affects both hooks-routes.ts and mcp-routes.ts

Impact:
- Linux/WSL: Fixes incorrect directory creation
- Windows: No behavior change, maintains correct functionality

Fixes project-level hook settings being saved to wrong location when
using Dashboard frontend on Linux/WSL systems.
This commit is contained in:
rhyme
2025-12-23 17:58:33 +08:00
parent 8eb42816f1
commit 87ffd283ce
2 changed files with 4 additions and 4 deletions

View File

@@ -31,8 +31,8 @@ const GLOBAL_SETTINGS_PATH = join(homedir(), '.claude', 'settings.json');
* @returns {string}
*/
function getProjectSettingsPath(projectPath) {
const normalizedPath = projectPath.replace(/\//g, '\\').replace(/^\\([a-zA-Z])\\/, '$1:\\');
return join(normalizedPath, '.claude', 'settings.json');
// path.join automatically handles cross-platform path separators
return join(projectPath, '.claude', 'settings.json');
}
/**

View File

@@ -1000,8 +1000,8 @@ function writeSettingsFile(filePath, settings) {
* @returns {string}
*/
function getProjectSettingsPath(projectPath) {
const normalizedPath = projectPath.replace(/\//g, '\\').replace(/^\\([a-zA-Z])\\/, '$1:\\');
return join(normalizedPath, '.claude', 'settings.json');
// path.join automatically handles cross-platform path separators
return join(projectPath, '.claude', 'settings.json');
}
// ========================================