Skip to content
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"iconv-lite": "^0.4.15",
"moment": "2.17.1",
"url-relative": "^1.0.0",
"urlencode": "^1.1.0",
"vscode-debugadapter": "^1.11.0",
"vscode-debugprotocol": "^1.11.0",
"xmldom": "^0.1.22"
Expand Down
5 changes: 5 additions & 0 deletions src/custom-typings/urlencode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

declare module 'urlencode' {
export function decode(str: string, charset?: string): string;
export function encode(str: string, charset?: string): string;
}
3 changes: 2 additions & 1 deletion src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import urlRelative = require('url-relative');
import fileUrl = require('file-url');
import * as url from 'url';
import * as path from 'path';
import {decode} from 'urlencode';

/** converts a server-side XDebug file URI to a local path for VS Code with respect to source root settings */
export function convertDebuggerPathToClient(fileUri: string|url.Url, localSourceRoot?: string, serverSourceRoot?: string): string {
if (typeof fileUri === 'string') {
fileUri = url.parse(fileUri);
}
// convert the file URI to a path
let serverPath = decodeURI(fileUri.pathname!);
let serverPath = decode(fileUri.pathname!);
// strip the trailing slash from Windows paths (indicated by a drive letter with a colon)
const serverIsWindows = /^\/[a-zA-Z]:\//.test(serverPath);
if (serverIsWindows) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ describe('paths', () => {
(process.platform !== 'win32' ? it : it.skip)('should convert a unix URI to a unix path', () => {
assert.equal(convertDebuggerPathToClient('file:///home/felix/test.php'), '/home/felix/test.php');
});
(process.platform === 'win32' ? it : it.skip)('should handle non-unicode special characters', () => {
assert.equal(
convertDebuggerPathToClient('file:///d:/arx%20iT/2-R%C3%A9alisation/mmi/V1.0/Web/core/header.php'),
'd:\\arx iT\\2-Réalisation\\mmi\\V1.0\\Web\\core\\header.php'
);
});
});
describe('with source mapping', () => {
(process.platform !== 'win32' ? it : it.skip)('should convert a unix URI to a unix path', () => {
Expand Down