@@ -5,7 +5,8 @@ import * as _ from 'lodash';
5
5
6
6
export class NativeScriptPathTransformer extends UrlPathTransformer {
7
7
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" )
9
10
} ;
10
11
11
12
private targetPlatform : string ;
@@ -21,6 +22,8 @@ export class NativeScriptPathTransformer extends UrlPathTransformer {
21
22
}
22
23
23
24
if ( _ . startsWith ( scriptUrl , "mdha:" ) )
25
+
26
+
24
27
{
25
28
scriptUrl = _ . trimStart ( scriptUrl , "mdha:" ) ;
26
29
}
@@ -31,14 +34,16 @@ export class NativeScriptPathTransformer extends UrlPathTransformer {
31
34
}
32
35
33
36
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 ) ;
42
47
43
48
const absolutePath = path . resolve ( path . join ( webRoot , relativePath ) ) ;
44
49
0 commit comments