mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 23:53:24 +02:00
Address PR review comments: fix UNC path handling, improve test coverage, remove problematic test files
- Fixed UNC path handling bug in normalizePath function to preserve leading double backslashes - Added comprehensive test coverage for drive letter capitalization and UNC paths - Removed file-operations.test.ts and core-functionality.test.ts as they were testing their own code rather than actual server functionality - All path-utils tests now pass with 100% coverage of the actual utility functions
This commit is contained in:
@@ -53,11 +53,28 @@ export function normalizePath(p: string): string {
|
||||
// Convert WSL or Unix-style Windows paths to Windows format
|
||||
p = convertToWindowsPath(p);
|
||||
|
||||
// Handle double backslashes and ensure proper escaping
|
||||
p = p.replace(/\\\\/g, '\\');
|
||||
// Check if this is a UNC path before normalization
|
||||
const isUNCPath = p.startsWith('\\\\');
|
||||
|
||||
// For non-UNC paths, normalize double backslashes first
|
||||
if (!isUNCPath) {
|
||||
p = p.replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
// Use Node's path normalization, which handles . and .. segments
|
||||
const normalized = path.normalize(p);
|
||||
let normalized = path.normalize(p);
|
||||
|
||||
// Handle UNC paths after normalization to preserve the leading \\
|
||||
if (isUNCPath) {
|
||||
// Ensure UNC path starts with exactly two backslashes
|
||||
if (normalized.startsWith('\\') && !normalized.startsWith('\\\\')) {
|
||||
normalized = '\\' + normalized;
|
||||
}
|
||||
// Normalize any remaining double backslashes in the rest of the path
|
||||
normalized = normalized.replace(/^(\\\\)(.*)/, (match, leading, rest) => {
|
||||
return leading + rest.replace(/\\\\/g, '\\');
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Windows paths: convert slashes and ensure drive letter is capitalized
|
||||
if (normalized.match(/^[a-zA-Z]:|^\/mnt\/[a-z]\/|^\/[a-z]\//i)) {
|
||||
|
||||
Reference in New Issue
Block a user