This repository was archived by the owner on Jul 13, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 85
85
var SystemLoader = function ( options ) {
86
86
Loader . call ( this , options || { } ) ;
87
87
88
+ var baseURL ;
88
89
// Set default baseURL and paths
89
- if ( typeof location != 'undefined' && location . href ) {
90
- var href = __global . location . href . split ( '#' ) [ 0 ] . split ( '?' ) [ 0 ] ;
91
- this . baseURL = href . substring ( 0 , href . lastIndexOf ( '/' ) + 1 ) ;
90
+ if ( isWorker ) {
91
+ baseURL = __global . location . href ;
92
+ }
93
+ else if ( typeof document != 'undefined' ) {
94
+ baseURL = document . baseURI ;
95
+
96
+ if ( ! baseURL ) {
97
+ var bases = document . getElementsByTagName ( 'base' ) ;
98
+ baseURL = bases [ 0 ] && bases [ 0 ] . href || window . location . href ;
99
+ }
100
+
101
+ // sanitize out the hash and querystring
102
+ // removes the username and password, which could be adjusted
103
+ baseURL = new URL ( baseURL ) ;
104
+ baseURL = baseURL . origin + baseURL . pathname . substr ( 0 , baseURL . pathname . lastIndexOf ( '/' ) + 1 ) ;
92
105
}
93
106
else if ( typeof process != 'undefined' && process . cwd ) {
94
- this . baseURL = 'file://' + ( isWindows ? '/' : '' ) + process . cwd ( ) + '/' ;
107
+ baseURL = 'file://' + ( isWindows ? '/' : '' ) + process . cwd ( ) + '/' ;
95
108
if ( isWindows )
96
- this . baseURL = this . baseURL . replace ( / \\ / g, '/' ) ;
109
+ baseURL = baseURL . replace ( / \\ / g, '/' ) ;
97
110
}
98
111
else {
99
112
throw new TypeError ( 'No environment baseURL' ) ;
100
113
}
114
+
115
+ this . baseURL = baseURL ;
101
116
this . paths = { } ;
102
117
} ;
103
118
You can’t perform that action at this time.
0 commit comments