File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -580,9 +580,12 @@ jQuery.extend({
580580
581581 // A cross-domain request is in order when we have a protocol:host:port mismatch
582582 if ( s . crossDomain == null ) {
583- parts = rurl . exec ( s . url . toLowerCase ( ) ) || false ;
584- s . crossDomain = parts && ( parts . join ( ":" ) + ( parts [ 3 ] ? "" : parts [ 1 ] === "http:" ? 80 : 443 ) ) !==
585- ( ajaxLocParts . join ( ":" ) + ( ajaxLocParts [ 3 ] ? "" : ajaxLocParts [ 1 ] === "http:" ? 80 : 443 ) ) ;
583+ parts = rurl . exec ( s . url . toLowerCase ( ) ) ;
584+ s . crossDomain = ! ! ( parts &&
585+ ( parts [ 1 ] !== ajaxLocParts [ 1 ] || parts [ 2 ] !== ajaxLocParts [ 2 ] ||
586+ ( parts [ 3 ] || ( parts [ 1 ] === "http:" ? 80 : 443 ) ) !=
587+ ( ajaxLocParts [ 3 ] || ( ajaxLocParts [ 1 ] === "http:" ? 80 : 443 ) ) )
588+ ) ;
586589 }
587590
588591 // Convert data if not already a string
Original file line number Diff line number Diff line change @@ -511,12 +511,22 @@ test(".ajax() - hash", function() {
511511
512512test ( "jQuery ajax - cross-domain detection" , function ( ) {
513513
514- expect ( 6 ) ;
514+ expect ( 7 ) ;
515515
516516 var loc = document . location ,
517+ samePort = loc . port || ( loc . protocol === "http:" ? 80 : 443 ) ,
517518 otherPort = loc . port === 666 ? 667 : 666 ,
518519 otherProtocol = loc . protocol === "http:" ? "https:" : "http:" ;
519520
521+ jQuery . ajax ( {
522+ dataType : "jsonp" ,
523+ url : loc . protocol + "//" + loc . host + ":" + samePort ,
524+ beforeSend : function ( _ , s ) {
525+ ok ( ! s . crossDomain , "Test matching ports are not detected as cross-domain" ) ;
526+ return false ;
527+ }
528+ } ) ;
529+
520530 jQuery . ajax ( {
521531 dataType : "jsonp" ,
522532 url : otherProtocol + "//" + loc . host ,
You can’t perform that action at this time.
0 commit comments