Permalink
Browse files

Merge pull request #201 from OliverJAsh/patch-1

IE8/9 (XDomainRequest): throw if cross scheme
2 parents b4a02a9 + b032906 commit 22da21c5de609d5b75ee21eb4484bce42c474973 @ded committed Dec 20, 2015
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/reqwest.js
View
@@ -58,6 +58,11 @@
if (xhr && 'withCredentials' in xhr) {
return xhr
} else if (context[xDomainRequest]) {
+ var protocolRegExp = /^https?/;
+ if (window.location.href.match(protocolRegExp)[0] !== o.url.match(protocolRegExp)[0]) {
+ throw new Error('XDomainRequest: requests must be targeted to the same scheme as the hosting page.')
+ // As per: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
+ }
return new XDomainRequest()
} else {
throw new Error('Browser does not support cross-origin requests')

0 comments on commit 22da21c

Please sign in to comment.