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({
580
580
581
581
// A cross-domain request is in order when we have a protocol:host:port mismatch
582
582
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
+ ) ;
586
589
}
587
590
588
591
// 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() {
511
511
512
512
test ( "jQuery ajax - cross-domain detection" , function ( ) {
513
513
514
- expect ( 6 ) ;
514
+ expect ( 7 ) ;
515
515
516
516
var loc = document . location ,
517
+ samePort = loc . port || ( loc . protocol === "http:" ? 80 : 443 ) ,
517
518
otherPort = loc . port === 666 ? 667 : 666 ,
518
519
otherProtocol = loc . protocol === "http:" ? "https:" : "http:" ;
519
520
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
+
520
530
jQuery . ajax ( {
521
531
dataType : "jsonp" ,
522
532
url : otherProtocol + "//" + loc . host ,
You can’t perform that action at this time.
0 commit comments