1
1
var ajax = require ( 'can-util/dom/ajax/ajax' ) ;
2
2
var namespace = require ( "can-namespace" ) ;
3
+ var makeMap = require ( 'can-util/js/make-map/make-map' ) ;
3
4
4
5
QUnit = require ( 'steal-qunit' ) ;
5
6
@@ -23,10 +24,11 @@ var makeFixture = function(XHR){
23
24
} ;
24
25
} ;
25
26
26
- // A helper to make a predicate for a given array that checks whether it contains a given value:
27
- var makePredicateContains = function ( arr ) {
27
+ // A helper to make a predicate for a given comma-separated list that checks whether it contains a given value:
28
+ var makePredicateContains = function ( str ) {
29
+ var obj = makeMap ( str ) ;
28
30
return function ( val ) {
29
- return arr . indexOf ( val ) !== - 1 ;
31
+ return obj [ val ] ;
30
32
} ;
31
33
} ;
32
34
@@ -121,12 +123,9 @@ if(typeof XDomainRequest === 'undefined') {
121
123
122
124
// CORS simple requests: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests
123
125
var isSimpleRequest = true , restore ;
124
- var isSimpleMethod = makePredicateContains ( [ 'GET' , 'POST' , 'HEAD' ] ) ;
125
- var isSimpleHeader = makePredicateContains ( [
126
- 'Accept' , 'Accept-Language' , 'Content-Language' , 'Content-Type' ,
127
- 'DPR' , 'Downlink' , 'Save-Data' , 'Viewport-Width' , 'Width'
128
- ] ) ;
129
- var isSimpleContentType = makePredicateContains ( [ 'application/x-www-form-urlencoded' , 'multipart/form-data' , 'text/plain' ] ) ;
126
+ var isSimpleMethod = makePredicateContains ( "GET,POST,HEAD" ) ;
127
+ var isSimpleHeader = makePredicateContains ( "Accept,Accept-Language,Content-Language,Content-Type,DPR,Downlink,Save-Data,Viewport-Width,Width" ) ;
128
+ var isSimpleContentType = makePredicateContains ( "application/x-www-form-urlencoded,multipart/form-data,text/plain" ) ;
130
129
131
130
restore = makeFixture ( function ( ) {
132
131
this . open = function ( type , url ) {
0 commit comments