Permalink
Browse files

Merge branch 'bug7531' of https://github.com/csnover/jquery into csno…

…ver-bug7531
  • Loading branch information...
2 parents b00ab56 + c04500a commit 6c6812492858066043dd63525d94e2d334c96c3f @jeresig jeresig committed Dec 6, 2010
Showing with 14 additions and 1 deletion.
  1. +4 −1 src/ajax.js
  2. +10 −0 test/unit/ajax.js
View
@@ -198,7 +198,10 @@ jQuery.extend({
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type);
- s.url = s.url.replace( rhash, "" );
+ // toString fixes people passing a window.location or
+ // document.location to $.ajax, which worked in 1.4.2 and
+ // earlier (bug #7531). It should be removed in 1.5.
+ s.url = ("" + s.url).replace( rhash, "" );
// Use original (not extended) context object if it was provided
s.context = origSettings && origSettings.context != null ? origSettings.context : s;
View
@@ -1361,6 +1361,16 @@ test("jQuery.ajax - active counter", function() {
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
});
+test( "jQuery.ajax - Location object as url (#7531)", 1, function () {
+ var success = false;
+ try {
+ var xhr = jQuery.ajax({ url: document.location });
+ success = true;
+ xhr.abort();
+ } catch (e) {}
+
+ ok( success, "document.location did not generate exception" );
+});
}

0 comments on commit 6c68124

Please sign in to comment.