From 87ffd283ce2704e01299196660a8b1ebd158f7ad Mon Sep 17 00:00:00 2001 From: rhyme Date: Tue, 23 Dec 2025 17:58:33 +0800 Subject: [PATCH] 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. --- ccw/src/core/routes/hooks-routes.ts | 4 ++-- ccw/src/core/routes/mcp-routes.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ccw/src/core/routes/hooks-routes.ts b/ccw/src/core/routes/hooks-routes.ts index a3175bdb..c316c5f9 100644 --- a/ccw/src/core/routes/hooks-routes.ts +++ b/ccw/src/core/routes/hooks-routes.ts @@ -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'); } /** diff --git a/ccw/src/core/routes/mcp-routes.ts b/ccw/src/core/routes/mcp-routes.ts index 343cfa0e..b9164ec1 100644 --- a/ccw/src/core/routes/mcp-routes.ts +++ b/ccw/src/core/routes/mcp-routes.ts @@ -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'); } // ========================================