@@ -17,6 +17,7 @@ function assertConfigurationIs(actual, expected) {
17
17
QUnit . test ( 'Default configuration' , ( ) => {
18
18
var result = loader . ConfigurationOptionsUtil . mergeConfigurationOptions ( ) ;
19
19
assertConfigurationIs ( result , {
20
+ allowJsExtension : false ,
20
21
baseUrl : '' ,
21
22
catchError : false ,
22
23
ignoreDuplicateModules : [ ] ,
@@ -31,6 +32,7 @@ QUnit.test('Default configuration', () => {
31
32
} ) ;
32
33
function createSimpleKnownConfigurationOptions ( ) {
33
34
return loader . ConfigurationOptionsUtil . mergeConfigurationOptions ( {
35
+ allowJsExtension : false ,
34
36
baseUrl : 'myBaseUrl' ,
35
37
catchError : true ,
36
38
ignoreDuplicateModules : [ 'a' ] ,
@@ -46,6 +48,7 @@ function createSimpleKnownConfigurationOptions() {
46
48
QUnit . test ( 'Simple known configuration options' , ( ) => {
47
49
var result = createSimpleKnownConfigurationOptions ( ) ;
48
50
assertConfigurationIs ( result , {
51
+ allowJsExtension : false ,
49
52
baseUrl : 'myBaseUrl/' ,
50
53
catchError : true ,
51
54
ignoreDuplicateModules : [ 'a' ] ,
@@ -64,6 +67,7 @@ QUnit.test('Overwriting known configuration options', () => {
64
67
baseUrl : ''
65
68
} , createSimpleKnownConfigurationOptions ( ) ) ;
66
69
assertConfigurationIs ( result , {
70
+ allowJsExtension : false ,
67
71
baseUrl : '' ,
68
72
catchError : true ,
69
73
ignoreDuplicateModules : [ 'a' ] ,
@@ -80,6 +84,7 @@ QUnit.test('Overwriting known configuration options', () => {
80
84
baseUrl : '/'
81
85
} , createSimpleKnownConfigurationOptions ( ) ) ;
82
86
assertConfigurationIs ( result , {
87
+ allowJsExtension : false ,
83
88
baseUrl : '/' ,
84
89
catchError : true ,
85
90
ignoreDuplicateModules : [ 'a' ] ,
@@ -96,6 +101,7 @@ QUnit.test('Overwriting known configuration options', () => {
96
101
catchError : false
97
102
} , createSimpleKnownConfigurationOptions ( ) ) ;
98
103
assertConfigurationIs ( result , {
104
+ allowJsExtension : false ,
99
105
baseUrl : 'myBaseUrl/' ,
100
106
catchError : false ,
101
107
ignoreDuplicateModules : [ 'a' ] ,
@@ -112,6 +118,7 @@ QUnit.test('Overwriting known configuration options', () => {
112
118
ignoreDuplicateModules : [ 'b' ]
113
119
} , createSimpleKnownConfigurationOptions ( ) ) ;
114
120
assertConfigurationIs ( result , {
121
+ allowJsExtension : false ,
115
122
baseUrl : 'myBaseUrl/' ,
116
123
catchError : true ,
117
124
ignoreDuplicateModules : [ 'a' , 'b' ] ,
@@ -128,6 +135,7 @@ QUnit.test('Overwriting known configuration options', () => {
128
135
paths : { 'a' : 'c' }
129
136
} , createSimpleKnownConfigurationOptions ( ) ) ;
130
137
assertConfigurationIs ( result , {
138
+ allowJsExtension : false ,
131
139
baseUrl : 'myBaseUrl/' ,
132
140
catchError : true ,
133
141
ignoreDuplicateModules : [ 'a' ] ,
@@ -144,6 +152,7 @@ QUnit.test('Overwriting known configuration options', () => {
144
152
config : { 'e' : { } }
145
153
} , createSimpleKnownConfigurationOptions ( ) ) ;
146
154
assertConfigurationIs ( result , {
155
+ allowJsExtension : false ,
147
156
baseUrl : 'myBaseUrl/' ,
148
157
catchError : true ,
149
158
ignoreDuplicateModules : [ 'a' ] ,
@@ -160,6 +169,7 @@ QUnit.test('Overwriting known configuration options', () => {
160
169
config : { 'd' : { 'a' : 'a' } }
161
170
} , createSimpleKnownConfigurationOptions ( ) ) ;
162
171
assertConfigurationIs ( result , {
172
+ allowJsExtension : false ,
163
173
baseUrl : 'myBaseUrl/' ,
164
174
catchError : true ,
165
175
ignoreDuplicateModules : [ 'a' ] ,
@@ -175,6 +185,7 @@ QUnit.test('Overwriting known configuration options', () => {
175
185
QUnit . test ( 'Overwriting unknown configuration options' , ( ) => {
176
186
var result = loader . ConfigurationOptionsUtil . mergeConfigurationOptions ( ) ;
177
187
assertConfigurationIs ( result , {
188
+ allowJsExtension : false ,
178
189
baseUrl : '' ,
179
190
catchError : false ,
180
191
ignoreDuplicateModules : [ ] ,
@@ -191,6 +202,7 @@ QUnit.test('Overwriting unknown configuration options', () => {
191
202
unknownKey1 : 'value1'
192
203
} , result ) ;
193
204
assertConfigurationIs ( result , {
205
+ allowJsExtension : false ,
194
206
baseUrl : '' ,
195
207
catchError : false ,
196
208
ignoreDuplicateModules : [ ] ,
@@ -208,6 +220,7 @@ QUnit.test('Overwriting unknown configuration options', () => {
208
220
unknownKey2 : 'value2'
209
221
} , result ) ;
210
222
assertConfigurationIs ( result , {
223
+ allowJsExtension : false ,
211
224
baseUrl : '' ,
212
225
catchError : false ,
213
226
ignoreDuplicateModules : [ ] ,
@@ -226,6 +239,7 @@ QUnit.test('Overwriting unknown configuration options', () => {
226
239
unknownKey2 : 'new-value2'
227
240
} , result ) ;
228
241
assertConfigurationIs ( result , {
242
+ allowJsExtension : false ,
229
243
baseUrl : '' ,
230
244
catchError : false ,
231
245
ignoreDuplicateModules : [ ] ,
@@ -277,6 +291,55 @@ QUnit.test('moduleIdToPath', () => {
277
291
QUnit . equal ( config . moduleIdToPaths ( 'https://a/b/c/d' ) , 'https://a/b/c/d.js?suffix' ) ;
278
292
QUnit . equal ( config . moduleIdToPaths ( 'https://a' ) , 'https://a.js?suffix' ) ;
279
293
} ) ;
294
+ QUnit . test ( 'moduleIdToPath with allowJsExtension' , ( ) => {
295
+ var config = new loader . Configuration ( new loader . Environment ( ) , {
296
+ allowJsExtension : true ,
297
+ baseUrl : 'prefix' ,
298
+ urlArgs : 'suffix' ,
299
+ paths : {
300
+ 'a' : 'newa' ,
301
+ 'knockout' : 'http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js' ,
302
+ 'knockout.js' : 'http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js' ,
303
+ 'editor' : '/src/editor'
304
+ }
305
+ } ) ;
306
+ // baseUrl is applied
307
+ QUnit . equal ( config . moduleIdToPaths ( 'b/c/d' ) , 'prefix/b/c/d.js?suffix' ) ;
308
+ QUnit . equal ( config . moduleIdToPaths ( 'b/c/d.js' ) , 'prefix/b/c/d.js?suffix' ) ;
309
+ // paths rules are applied
310
+ QUnit . equal ( config . moduleIdToPaths ( 'a' ) , 'prefix/newa.js?suffix' ) ;
311
+ QUnit . equal ( config . moduleIdToPaths ( 'a.js' ) , 'prefix/newa.js?suffix' ) ;
312
+ QUnit . equal ( config . moduleIdToPaths ( 'a/b/c/d' ) , 'prefix/newa/b/c/d.js?suffix' ) ;
313
+ QUnit . equal ( config . moduleIdToPaths ( 'a/b/c/d.js' ) , 'prefix/newa/b/c/d.js?suffix' ) ;
314
+ // paths rules check if value is an absolute path
315
+ QUnit . equal ( config . moduleIdToPaths ( 'knockout' ) , 'http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js?suffix' ) ;
316
+ QUnit . equal ( config . moduleIdToPaths ( 'knockout.js' ) , 'http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js?suffix' ) ;
317
+ // modules redirected to / still get .js appended
318
+ QUnit . equal ( config . moduleIdToPaths ( 'editor/x' ) , '/src/editor/x.js?suffix' ) ;
319
+ QUnit . equal ( config . moduleIdToPaths ( 'editor/x.js' ) , '/src/editor/x.js?suffix' ) ;
320
+ // modules starting with / skip baseUrl + paths rules
321
+ QUnit . equal ( config . moduleIdToPaths ( '/b/c/d' ) , '/b/c/d.js?suffix' ) ;
322
+ QUnit . equal ( config . moduleIdToPaths ( '/b/c/d.js' ) , '/b/c/d.js?suffix' ) ;
323
+ QUnit . equal ( config . moduleIdToPaths ( '/a/b/c/d' ) , '/a/b/c/d.js?suffix' ) ;
324
+ QUnit . equal ( config . moduleIdToPaths ( '/a/b/c/d.js' ) , '/a/b/c/d.js?suffix' ) ;
325
+ QUnit . equal ( config . moduleIdToPaths ( '/a' ) , '/a.js?suffix' ) ;
326
+ QUnit . equal ( config . moduleIdToPaths ( '/a.js' ) , '/a.js?suffix' ) ;
327
+ // modules starting with http:// or https:// skip baseUrl + paths rules
328
+ QUnit . equal ( config . moduleIdToPaths ( 'file:///c:/a/b/c' ) , 'file:///c:/a/b/c.js?suffix' ) ;
329
+ QUnit . equal ( config . moduleIdToPaths ( 'file:///c:/a/b/c.js' ) , 'file:///c:/a/b/c.js?suffix' ) ;
330
+ QUnit . equal ( config . moduleIdToPaths ( 'http://b/c/d' ) , 'http://b/c/d.js?suffix' ) ;
331
+ QUnit . equal ( config . moduleIdToPaths ( 'http://b/c/d.js' ) , 'http://b/c/d.js?suffix' ) ;
332
+ QUnit . equal ( config . moduleIdToPaths ( 'http://a/b/c/d' ) , 'http://a/b/c/d.js?suffix' ) ;
333
+ QUnit . equal ( config . moduleIdToPaths ( 'http://a/b/c/d.js' ) , 'http://a/b/c/d.js?suffix' ) ;
334
+ QUnit . equal ( config . moduleIdToPaths ( 'http://a' ) , 'http://a.js?suffix' ) ;
335
+ QUnit . equal ( config . moduleIdToPaths ( 'http://a.js' ) , 'http://a.js?suffix' ) ;
336
+ QUnit . equal ( config . moduleIdToPaths ( 'https://b/c/d' ) , 'https://b/c/d.js?suffix' ) ;
337
+ QUnit . equal ( config . moduleIdToPaths ( 'https://b/c/d.js' ) , 'https://b/c/d.js?suffix' ) ;
338
+ QUnit . equal ( config . moduleIdToPaths ( 'https://a/b/c/d' ) , 'https://a/b/c/d.js?suffix' ) ;
339
+ QUnit . equal ( config . moduleIdToPaths ( 'https://a/b/c/d.js' ) , 'https://a/b/c/d.js?suffix' ) ;
340
+ QUnit . equal ( config . moduleIdToPaths ( 'https://a' ) , 'https://a.js?suffix' ) ;
341
+ QUnit . equal ( config . moduleIdToPaths ( 'https://a.js' ) , 'https://a.js?suffix' ) ;
342
+ } ) ;
280
343
QUnit . test ( 'requireToUrl' , ( ) => {
281
344
var config = new loader . Configuration ( new loader . Environment ( ) , {
282
345
baseUrl : 'prefix' ,
0 commit comments