Comparing version 0.3.3 to 0.3.4
31
index.js
@@ -5,2 +5,4 @@ /*global window*/ | ||
, protocolLess = /^\/\/[^\/]+\// | ||
, hasProtocol = /^https?:\/\// | ||
, messages = { | ||
@@ -11,6 +13,7 @@ "0": "Internal XMLHttpRequest Error" | ||
} | ||
, Base = window.XDomainRequest ? | ||
window.XDomainRequest : | ||
window.XMLHttpRequest | ||
, XHR = window.XMLHttpRequest | ||
, XDR = "withCredentials" in (new XHR()) ? | ||
window.XMLHttpRequest : window.XDomainRequest | ||
createXHR.defaults = {} | ||
@@ -24,4 +27,20 @@ | ||
var xhr = new Base() | ||
, load = options.status === false ? call(xhr, callback) : | ||
var xhr | ||
, uri = options.uri | ||
if ("cors" in options) { | ||
if (options.cors) { | ||
xhr = new XDR() | ||
} else { | ||
xhr = new XHR() | ||
} | ||
} else { | ||
if (protocolLess.test(uri) || hasProtocol.test(uri)) { | ||
xhr = new XDR() | ||
} else { | ||
xhr = new XHR() | ||
} | ||
} | ||
var load = options.status === false ? call(xhr, callback) : | ||
callWithStatus(xhr, callback) | ||
@@ -38,3 +57,3 @@ | ||
xhr.timeout = "timeout" in options ? options.timeout : 5000 | ||
xhr.open(options.method, options.uri) | ||
xhr.open(options.method, uri) | ||
@@ -41,0 +60,0 @@ if (options.headers && xhr.setRequestHeader) { |
{ | ||
"name": "xhr", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "small xhr abstraction", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -38,2 +38,9 @@ # xhr | ||
### `options.cors` | ||
Specify whether this is a cross domain request. Used in IE<10 | ||
to use `XDomainRequest` instead of `XMLHttpRequest`. If not | ||
specified the library will pick `XDomainRequest` if the uri | ||
has a protocol. | ||
### `options.data` | ||
@@ -40,0 +47,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6592
84
77