can-ajax
Advanced tools
Comparing version 2.4.6 to 2.4.7
@@ -53,2 +53,52 @@ | ||
QUnit.test("The variable isPost will check for PATCH types in ajax requests (#75)", function (assert) { | ||
var done = assert.async(); | ||
var restore = makeFixture(function () { | ||
var o = {}; | ||
this.open = function (type, url) { | ||
o.url = url; | ||
}; | ||
this.send = function (data) { | ||
o.data = data; | ||
this.readyState = 4; | ||
this.status = 200; | ||
this.responseText = JSON.stringify(o); | ||
this.onreadystatechange(); | ||
}; | ||
this.setRequestHeader = function (header, value) { | ||
if (header === "Content-Type") { | ||
o[header] = value; | ||
} | ||
}; | ||
}); | ||
var origin = parseURI(GLOBAL().location.href); | ||
var url = origin.protocol + origin.authority + "/food"; | ||
ajax({ | ||
url: url, | ||
type: "post", | ||
data: JSON.stringify({ food: "bar"}), | ||
}).then(function(resp){ | ||
console.log("resp in post", resp); | ||
assert.equal(resp.data, `{"food":"bar"}`); | ||
}); | ||
ajax({ | ||
url: url, | ||
type: "patch", | ||
data: {food: "baz"}, | ||
}).then(function(resp){ | ||
assert.deepEqual(resp.data, `{"food":"baz"}`); | ||
}).then(function() { | ||
restore(); | ||
done(); | ||
}); | ||
}); | ||
QUnit.test("synchronous get request", function(assert) { | ||
@@ -331,4 +381,2 @@ var done = assert.async(); | ||
}); | ||
}); | ||
@@ -778,3 +826,3 @@ | ||
}); | ||
ajax({ | ||
@@ -781,0 +829,0 @@ type: "get", |
@@ -109,2 +109,3 @@ 'use strict'; | ||
var _xhrResp = function (xhr, options) { | ||
try{ | ||
@@ -169,3 +170,2 @@ var type = (options.dataType || xhr.getResponseHeader("Content-Type").split(";")[0]); | ||
} | ||
//how jquery handles check for cross domain | ||
@@ -191,2 +191,3 @@ if(o.crossDomain == null){ | ||
xhr.onreadystatechange = function () { | ||
try { | ||
@@ -224,3 +225,3 @@ if (xhr.readyState === 4) { | ||
var isJsonContentType = o.contentType === contentTypes.json; | ||
var isPost = type === "POST" || type === "PUT"; | ||
var isPost = type === "POST" || type === "PUT" || type === "PATCH"; | ||
if (!isPost && o.data) { | ||
@@ -230,3 +231,2 @@ url += "?" + (isJsonContentType ? JSON.stringify(o.data) : param(o.data)); | ||
xhr.open(type, url, async); | ||
// For CORS to send a "simple" request (to avoid a preflight check), the following methods are allowed: GET/POST/HEAD, | ||
@@ -267,3 +267,2 @@ // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests | ||
} | ||
function send () { | ||
@@ -270,0 +269,0 @@ if(!isAborted) { |
@@ -1,2 +0,2 @@ | ||
/*can-ajax@2.4.5#can-ajax*/ | ||
/*can-ajax@2.4.6#can-ajax*/ | ||
define([ | ||
@@ -158,3 +158,3 @@ 'require', | ||
var isJsonContentType = o.contentType === contentTypes.json; | ||
var isPost = type === 'POST' || type === 'PUT'; | ||
var isPost = type === 'POST' || type === 'PUT' || type === 'PATCH'; | ||
if (!isPost && o.data) { | ||
@@ -161,0 +161,0 @@ url += '?' + (isJsonContentType ? JSON.stringify(o.data) : param(o.data)); |
@@ -1,2 +0,2 @@ | ||
/*can-ajax@2.4.5#can-ajax*/ | ||
/*can-ajax@2.4.6#can-ajax*/ | ||
'use strict'; | ||
@@ -147,3 +147,3 @@ var Global = require('can-globals/global/global'); | ||
var isJsonContentType = o.contentType === contentTypes.json; | ||
var isPost = type === 'POST' || type === 'PUT'; | ||
var isPost = type === 'POST' || type === 'PUT' || type === 'PATCH'; | ||
if (!isPost && o.data) { | ||
@@ -150,0 +150,0 @@ url += '?' + (isJsonContentType ? JSON.stringify(o.data) : param(o.data)); |
@@ -167,3 +167,3 @@ /*[process-shim]*/ | ||
/*can-ajax@2.4.5#can-ajax*/ | ||
/*can-ajax@2.4.6#can-ajax*/ | ||
define('can-ajax', [ | ||
@@ -325,3 +325,3 @@ 'require', | ||
var isJsonContentType = o.contentType === contentTypes.json; | ||
var isPost = type === 'POST' || type === 'PUT'; | ||
var isPost = type === 'POST' || type === 'PUT' || type === 'PATCH'; | ||
if (!isPost && o.data) { | ||
@@ -328,0 +328,0 @@ url += '?' + (isJsonContentType ? JSON.stringify(o.data) : param(o.data)); |
{ | ||
"name": "can-ajax", | ||
"version": "2.4.6", | ||
"version": "2.4.7", | ||
"description": "jQuery-inspired AJAX request library.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://canjs.com/doc/can-ajax.html", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
65161
1885
2