diff options
author | jaubourg <j@ubourg.net> | 2011-01-09 06:01:00 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-01-09 06:01:00 +0100 |
commit | afefb4f3d28f47c0a93cc9dfddfcbadb595a8efb (patch) | |
tree | 73c20f0ba02aa86f892755b46b3e294c8eb77ad3 /src | |
parent | d515068ee807efef29b6c8406171be4725d7154f (diff) | |
download | jquery-afefb4f3d28f47c0a93cc9dfddfcbadb595a8efb.tar.gz jquery-afefb4f3d28f47c0a93cc9dfddfcbadb595a8efb.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ajax.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ajax.js b/src/ajax.js index 744476f1a..207ef13aa 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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" ) { |