Browse Source

Fix logical error in origin check

master
Kegan Myers 8 years ago
parent
commit
1d0ccbbf13
  1. 2
      lib/Typertext/Http/HttpUrl.ts
  2. 4
      lib/Typertext/Transport/TransportChooser.ts

2
lib/Typertext/Http/HttpUrl.ts

@ -199,7 +199,7 @@ module Typertext.Http {
*
* @returns {boolean}
*/
public CrossOriginCheck(url:HttpUrl):boolean {
public SameOriginCheck(url:HttpUrl):boolean {
return (this.domain === url.GetDomain() && this.port === url.GetPort() && this.protocol === url.GetProtocol());
}
}

4
lib/Typertext/Transport/TransportChooser.ts

@ -32,8 +32,8 @@ module Typertext.Transport {
var ieLte9 = (ieTestDiv.getElementsByTagName("i").length === 1);
var origin = HttpUrl.FromUrl(window.location.href);
//If this is a CORS request in a modern browser
if (!origin.CrossOriginCheck(origin) || !ieLte9) {
//If this is a standard request, or a CORS request in a modern browser
if (origin.SameOriginCheck(origin) || !ieLte9) {
//Just use a standard XHR request
return XHR;
}