Skip to content

Commit 84d3d07

Browse files
committed
Support iOS mapping
1 parent 96a38ed commit 84d3d07

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/debug-adapter/nativeScriptPathTransformer.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as _ from 'lodash';
55

66
export class NativeScriptPathTransformer extends UrlPathTransformer {
77
private filePatterns = {
8-
android: new RegExp("^(file:)?/*data/(data|user/\\d+)/.*?/files/(.*)$", "i")
8+
android: new RegExp("^(file:)?/*data/(data|user/\\d+)/.*?/files/(.*)$", "i"),
9+
ios: new RegExp("^(file:)?/*(.*)$", "i")
910
};
1011

1112
private targetPlatform: string;
@@ -21,6 +22,8 @@ export class NativeScriptPathTransformer extends UrlPathTransformer {
2122
}
2223

2324
if (_.startsWith(scriptUrl, "mdha:"))
25+
26+
2427
{
2528
scriptUrl = _.trimStart(scriptUrl, "mdha:");
2629
}
@@ -31,14 +34,16 @@ export class NativeScriptPathTransformer extends UrlPathTransformer {
3134
}
3235

3336
const filePattern = this.filePatterns[this.targetPlatform];
34-
const pathSeparator = "\\";
35-
const altSeparator = "/";
36-
const altScriptUrl = scriptUrl.replace(pathSeparator, altSeparator);
37-
const matches = filePattern.exec(altScriptUrl);
38-
let relativePath = matches ? matches[3] : scriptUrl;
39-
40-
relativePath = relativePath.replace(altSeparator, pathSeparator);
41-
relativePath = relativePath.replace("tns_modules", "..\\node_modules");
37+
38+
const matches = filePattern.exec(scriptUrl)
39+
40+
let relativePath = scriptUrl;
41+
if(matches) {
42+
relativePath = this.targetPlatform === 'android' ? matches[3] : matches[2];
43+
}
44+
45+
const nodePath = path.join("..", "node_modules");
46+
relativePath = relativePath.replace("tns_modules", nodePath);
4247

4348
const absolutePath = path.resolve(path.join(webRoot, relativePath));
4449

0 commit comments

Comments
 (0)