Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions src/test/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down