Commit 7c9a5e60 authored by jaubourg's avatar jaubourg

Makes sure all converters keys are lowercased before any conversion is taking...

Makes sure all converters keys are lowercased before any conversion is taking place: dataTypes' names are now truly case insensitive. Unit test edited.
parent 485fa0c4
...@@ -842,8 +842,9 @@ function ajaxConvert( s, response ) { ...@@ -842,8 +842,9 @@ function ajaxConvert( s, response ) {
} }
var dataTypes = s.dataTypes, var dataTypes = s.dataTypes,
converters = s.converters, converters = {},
i, i,
key,
length = dataTypes.length, length = dataTypes.length,
tmp, tmp,
// Current and previous dataTypes // Current and previous dataTypes
...@@ -860,6 +861,16 @@ function ajaxConvert( s, response ) { ...@@ -860,6 +861,16 @@ function ajaxConvert( s, response ) {
// For each dataType in the chain // For each dataType in the chain
for( i = 1; i < length; i++ ) { for( i = 1; i < length; i++ ) {
// Create converters map
// with lowercased keys
if ( i === 1 ) {
for( key in s.converters ) {
if( typeof key === "string" ) {
converters[ key.toLowerCase() ] = s.converters[ key ];
}
}
}
// Get the dataTypes // Get the dataTypes
prev = current; prev = current;
current = dataTypes[ i ]; current = dataTypes[ i ];
......
...@@ -2077,12 +2077,12 @@ test("jQuery.ajax - transitive conversions", function() { ...@@ -2077,12 +2077,12 @@ test("jQuery.ajax - transitive conversions", function() {
jQuery.ajax( url("data/json.php") , { jQuery.ajax( url("data/json.php") , {
converters: { converters: {
"json myjson": function( data ) { "json myJson": function( data ) {
ok( true , "converter called" ); ok( true , "converter called" );
return data; return data;
} }
}, },
dataType: "myjson", dataType: "myJson",
success: function() { success: function() {
ok( true , "Transitive conversion worked" ); ok( true , "Transitive conversion worked" );
strictEqual( this.dataTypes[0] , "text" , "response was retrieved as text" ); strictEqual( this.dataTypes[0] , "text" , "response was retrieved as text" );
...@@ -2092,13 +2092,13 @@ test("jQuery.ajax - transitive conversions", function() { ...@@ -2092,13 +2092,13 @@ test("jQuery.ajax - transitive conversions", function() {
jQuery.ajax( url("data/json.php") , { jQuery.ajax( url("data/json.php") , {
converters: { converters: {
"json myjson": function( data ) { "json myJson": function( data ) {
ok( true , "converter called (*)" ); ok( true , "converter called (*)" );
return data; return data;
} }
}, },
contents: false, /* headers are wrong so we ignore them */ contents: false, /* headers are wrong so we ignore them */
dataType: "* myjson", dataType: "* myJson",
success: function() { success: function() {
ok( true , "Transitive conversion worked (*)" ); ok( true , "Transitive conversion worked (*)" );
strictEqual( this.dataTypes[0] , "text" , "response was retrieved as text (*)" ); strictEqual( this.dataTypes[0] , "text" , "response was retrieved as text (*)" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment