From: John Resig Date: Mon, 6 Dec 2010 22:22:02 +0000 (-0500) Subject: Merge branch 'bug7531' of https://github.com/csnover/jquery into csnover-bug7531 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=6c6812492858066043dd63525d94e2d334c96c3f;hp=b00ab56160a75c6aa3fdd21807c951ac8098aabc;p=jquery.git Merge branch 'bug7531' of https://github.com/csnover/jquery into csnover-bug7531 --- diff --git a/src/ajax.js b/src/ajax.js index e82a082..d20ad76 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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; diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 9e6f32d..a0f3d49 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -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" ); +}); }