Comparing version 1.11.0 to 1.12.0
@@ -59,5 +59,7 @@ var window = require("global/window") | ||
xhr.open(method, uri, !sync) | ||
if (options.cors) { | ||
if (options.cors && options.withCredentials !== false) { | ||
xhr.withCredentials = true | ||
} | ||
// Cannot set timeout with sync request | ||
@@ -64,0 +66,0 @@ if (!sync) { |
{ | ||
"name": "xhr", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "small xhr abstraction", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -36,3 +36,4 @@ # xhr | ||
body: String?, | ||
json: Object? | ||
json: Object?, | ||
withCredentials: Boolean? | ||
} | ||
@@ -104,2 +105,9 @@ xhr := (XhrOptions, Callback<Response>) => Request | ||
### `options.withCredentials` | ||
Specify whether user credentials are to be included in a cross-origin | ||
request. Sets [`xhr.withCredentials`][10]. Defaults to true | ||
when `options.cors` is true. | ||
## MIT Licenced | ||
@@ -116,1 +124,2 @@ | ||
[9]: http://xhr.spec.whatwg.org/#the-setrequestheader()-method | ||
[10]: http://xhr.spec.whatwg.org/#the-withcredentials-attribute |
@@ -23,1 +23,24 @@ var window = require("global/window") | ||
test("withCredentials option", function(assert) { | ||
var req = xhr({}, function () {}) | ||
assert.ok( | ||
!req.withCredentials, | ||
"withCredentials not true when nothing set in options" | ||
) | ||
req = xhr({ | ||
cors: true | ||
}, function () {}) | ||
assert.ok( | ||
req.withCredentials, | ||
"withCredentials set to true when cors is true in options" | ||
) | ||
req = xhr({ | ||
cors: true, | ||
withCredentials: false | ||
}, function () {}) | ||
assert.ok( | ||
!req.withCredentials, | ||
"withCredentials set to false when set to false in options" | ||
) | ||
assert.end() | ||
}) |
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
10530
149
123