Fixes #7465. Reworked the regexp and associated test for cross-domain detection so that it now includes ports. Added cross-domain detection tests for protocol, hostname and port.

This commit is contained in:
jaubourg 2011-01-09 06:01:00 +01:00
parent d515068ee8
commit afefb4f3d2
2 changed files with 59 additions and 2 deletions

View file

@ -10,7 +10,7 @@ var r20 = /%20/g,
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
rselectTextarea = /^(?:select|textarea)/i,
rts = /([?&])_=[^&]*/,
rurl = /^(\w+:)?\/\/([^\/?#]+)/,
rurl = /^(\w+:)?\/\/([^\/?#:]+)(?::(\d+))?/,
// Slice function
sliceFunc = Array.prototype.slice,
@ -520,7 +520,12 @@ jQuery.extend({
// Determine if a cross-domain request is in order
var parts = rurl.exec( s.url.toLowerCase() ),
loc = location;
s.crossDomain = !!( parts && ( parts[ 1 ] && parts[ 1 ] != loc.protocol || parts[ 2 ] != loc.host ) );
s.crossDomain = !!(
parts &&
( parts[ 1 ] && parts[ 1 ] != loc.protocol ||
parts[ 2 ] != loc.hostname ||
( parts[ 3 ] || 80 ) != ( loc.port || 80 ) )
);
// Convert data if not already a string
if ( s.data && s.processData && typeof s.data != "string" ) {