From ef7b1db9b4ba12053cabc6139fe898f8d30c1bbf Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Sat, 21 Oct 2017 19:31:24 -0700 Subject: [PATCH] Handle inconsistent casing --- src/paths.ts | 6 ++++++ src/test/paths.ts | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/paths.ts b/src/paths.ts index a1cab3e7..98956a51 100644 --- a/src/paths.ts +++ b/src/paths.ts @@ -31,6 +31,12 @@ export function convertDebuggerPathToClient(fileUri: string|url.Url, localSource /** converts a local path from VS Code to a server-side XDebug file URI with respect to source root settings */ export function convertClientPathToDebugger(localPath: string, localSourceRoot?: string, serverSourceRoot?: string): string { + if (localSourceRoot) { + localSourceRoot = localSourceRoot.replace(/^[a-zA-Z]:\\/, match => match.toLowerCase()); + } + if (serverSourceRoot) { + serverSourceRoot = serverSourceRoot.replace(/^[a-zA-Z]:\\/, match => match.toLowerCase()); + } let localFileUri = fileUrl(localPath, {resolve: false}); let serverFileUri: string; if (serverSourceRoot && localSourceRoot) { diff --git a/src/test/paths.ts b/src/test/paths.ts index e5c8e655..e44df3e5 100644 --- a/src/test/paths.ts +++ b/src/test/paths.ts @@ -47,6 +47,14 @@ describe('paths', () => { 'file:///var/www/test.php' ); }); + it('should convert a windows path with inconsistent casing to a unix URI', () => { + const localSourceRoot = 'C:\\Users\\felix\\myproject'; + const serverSourceRoot = '/var/www'; + assert.equal( + convertClientPathToDebugger('c:\\Users\\felix\\myproject\\test.php', localSourceRoot, serverSourceRoot), + 'file:///var/www/test.php' + ); + }); it('should convert a windows path to a windows URI', () => { const localSourceRoot = 'C:\\Users\\felix\\myproject'; const serverSourceRoot = 'C:\\Program Files\\Apache\\2.4\\htdocs';