mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 23:53:24 +02:00
fix(filesystem): ensure bare Windows drive letters normalize to root (#3434)
fix(filesystem): ensure bare Windows drive letters normalize to root Appends path.sep to bare drive letters (e.g. "C:") before calling path.normalize(), preventing them from normalizing to "C:." (current directory on drive) instead of "C:\" (drive root). Includes test coverage with platform mocking. Fixes #3418
This commit is contained in:
@@ -77,6 +77,12 @@ export function normalizePath(p: string): string {
|
||||
p = p.replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
// On Windows, if we have a bare drive letter (e.g. "C:"), append a separator
|
||||
// so path.normalize doesn't return "C:." which can break path validation.
|
||||
if (process.platform === 'win32' && /^[a-zA-Z]:$/.test(p)) {
|
||||
p = p + path.sep;
|
||||
}
|
||||
|
||||
// Use Node's path normalization, which handles . and .. segments
|
||||
let normalized = path.normalize(p);
|
||||
|
||||
@@ -116,3 +122,4 @@ export function expandHome(filepath: string): string {
|
||||
}
|
||||
return filepath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user