mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Handle a falsy URL in the settings object for jQuery.ajax. Fixes #10093, Closes gh-979
This commit is contained in:
parent
fcaef88968
commit
ce5784a480
@ -247,6 +247,7 @@ jQuery.extend({
|
|||||||
target = jQuery.ajaxSettings;
|
target = jQuery.ajaxSettings;
|
||||||
}
|
}
|
||||||
ajaxExtend( target, settings );
|
ajaxExtend( target, settings );
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -557,8 +558,9 @@ jQuery.extend({
|
|||||||
|
|
||||||
// Remove hash character (#7531: and string promotion)
|
// Remove hash character (#7531: and string promotion)
|
||||||
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
||||||
|
// Handle falsy url in the settings object (#10093: consistency with old signature)
|
||||||
// We also use the url parameter if available
|
// We also use the url parameter if available
|
||||||
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
||||||
|
|
||||||
// Extract dataTypes list
|
// Extract dataTypes list
|
||||||
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
|
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
|
||||||
|
@ -2725,4 +2725,38 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
|
|||||||
expect( 1 );
|
expect( 1 );
|
||||||
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
|
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("jQuery.ajax - falsy url as argument (#10093)", function() {
|
||||||
|
expect( 4 );
|
||||||
|
|
||||||
|
jQuery.ajaxSetup({ timeout: 0 });
|
||||||
|
|
||||||
|
stop();
|
||||||
|
|
||||||
|
jQuery.when(
|
||||||
|
jQuery.ajax("").success(function(){ ok( true, "settings object - empty string" ); }),
|
||||||
|
jQuery.ajax( false ).success(function(){ ok( true, "false" ); }),
|
||||||
|
jQuery.ajax( null ).success(function(){ ok( true, "null" ); }),
|
||||||
|
jQuery.ajax( undefined ).success(function(){ ok( true, "undefined" ); })
|
||||||
|
).always(function () {
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("jQuery.ajax - falsy url in settings object (#10093)", function() {
|
||||||
|
expect( 4 );
|
||||||
|
|
||||||
|
jQuery.ajaxSetup({ timeout: 0 });
|
||||||
|
|
||||||
|
stop();
|
||||||
|
|
||||||
|
jQuery.when(
|
||||||
|
jQuery.ajax({ url: "" }).success(function(){ ok( true, "settings object - empty string" ); }),
|
||||||
|
jQuery.ajax({ url: false }).success(function(){ ok( true, "false" ); }),
|
||||||
|
jQuery.ajax({ url: null }).success(function(){ ok( true, "null" ); }),
|
||||||
|
jQuery.ajax({ url: undefined }).success(function(){ ok( true, "undefined" ); })
|
||||||
|
).always(function () {
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user