@@ -19,45 +19,45 @@ const NativeModules = require('NativeModules');
19
19
20
20
import type { ResolvedAssetSource } from 'AssetSourceResolver' ;
21
21
22
- let _customSourceTransformer , _serverURL , _bundleSourceURL ;
22
+ let _customSourceTransformer , _serverURL , _scriptURL ;
23
23
24
24
function getDevServerURL ( ) : ?string {
25
25
if ( _serverURL === undefined ) {
26
26
var scriptURL = NativeModules . SourceCode . scriptURL ;
27
27
var match = scriptURL && scriptURL . match ( / ^ h t t p s ? : \/ \/ .* ?\/ / ) ;
28
28
if ( match ) {
29
- // Bundle was loaded from network
29
+ // jsBundle was loaded from network
30
30
_serverURL = match [ 0 ] ;
31
31
} else {
32
- // Bundle was loaded from file
32
+ // jsBundle was loaded from file
33
33
_serverURL = null ;
34
34
}
35
35
}
36
36
return _serverURL ;
37
37
}
38
38
39
- function getBundleSourceURL ( ) : ?string {
40
- if ( _bundleSourceURL === undefined ) {
39
+ function getScriptURL ( ) : ?string {
40
+ if ( _scriptURL === undefined ) {
41
41
const scriptURL = NativeModules . SourceCode . scriptURL ;
42
42
if ( ! scriptURL ) {
43
43
// scriptURL is falsy, we have nothing to go on here
44
- _bundleSourceURL = null ;
45
- return _bundleSourceURL ;
44
+ _scriptURL = null ;
45
+ return _scriptURL ;
46
46
}
47
47
if ( scriptURL . startsWith ( 'assets://' ) ) {
48
48
// android: running from within assets, no offline path to use
49
- _bundleSourceURL = null ;
50
- return _bundleSourceURL ;
49
+ _scriptURL = null ;
50
+ return _scriptURL ;
51
51
}
52
- _bundleSourceURL = scriptURL . substring ( 0 , scriptURL . lastIndexOf ( '/' ) + 1 ) ;
52
+ _scriptURL = scriptURL . substring ( 0 , scriptURL . lastIndexOf ( '/' ) + 1 ) ;
53
53
if ( ! scriptURL . startsWith ( 'file://' ) ) {
54
54
// Add file protocol in case we have an absolute file path and not a URL.
55
55
// This shouldn't really be necessary. scriptURL should be a URL.
56
- _bundleSourceURL = 'file://' + _bundleSourceURL ;
56
+ _scriptURL = 'file://' + _scriptURL ;
57
57
}
58
58
}
59
59
60
- return _bundleSourceURL ;
60
+ return _scriptURL ;
61
61
}
62
62
63
63
function setCustomSourceTransformer (
@@ -80,7 +80,7 @@ function resolveAssetSource(source: any): ?ResolvedAssetSource {
80
80
return null ;
81
81
}
82
82
83
- const resolver = new AssetSourceResolver ( getDevServerURL ( ) , getBundleSourceURL ( ) , asset ) ;
83
+ const resolver = new AssetSourceResolver ( getDevServerURL ( ) , getScriptURL ( ) , asset ) ;
84
84
if ( _customSourceTransformer ) {
85
85
return _customSourceTransformer ( resolver ) ;
86
86
}
0 commit comments