can-connect
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -397,6 +397,6 @@ @module {function} can-connect | ||
[can-connect/constructor/store/store.addInstanceReference] — Call when an instance is being used. | ||
[can-connect/constructor/store/store.deleteInstanceReference] — Call when an instance is no longer being used. | ||
[can-connect/constructor/store/store.addListReference] — Call when a list is being used. | ||
[can-connect/constructor/store/store.deleteListReference] — Called when a list is no longer being used. | ||
- [can-connect/constructor/store/store.addInstanceReference] — when an instance is being used. | ||
- [can-connect/constructor/store/store.deleteInstanceReference] — when an instance is no longer being used. | ||
- [can-connect/constructor/store/store.addListReference] — when a list is being used. | ||
- [can-connect/constructor/store/store.deleteListReference] — when a list is no longer being used. | ||
@@ -403,0 +403,0 @@ |
@@ -157,2 +157,22 @@ var QUnit = require("steal-qunit"); | ||
QUnit.test("contentType defaults to form-urlencoded for GET", function() { | ||
var connection = persist({ | ||
url: { | ||
getData: "GET /api/restaurants" | ||
} | ||
}); | ||
fixture({ | ||
"GET /api/restaurants": function(request){ | ||
equal(request.headers["Content-Type"], "application/x-www-form-urlencoded"); | ||
return request.data; | ||
} | ||
}); | ||
stop(); | ||
connection.getData({foo:"bar"}).then(function() { | ||
start(); | ||
}); | ||
}); | ||
QUnit.test("getting a real Promise back with functions", function() { | ||
@@ -159,0 +179,0 @@ var connection = persist({ |
@@ -131,3 +131,3 @@ /** | ||
this.ajax || ajax, | ||
findContentType(this.url), | ||
findContentType(this.url, defaultData.method), | ||
meta); | ||
@@ -146,3 +146,3 @@ return makePromise(promise); | ||
this.ajax || ajax, | ||
findContentType(this.url), | ||
findContentType(this.url, result.method), | ||
meta)); | ||
@@ -324,3 +324,3 @@ } | ||
var findContentType = function( url ) { | ||
var findContentType = function( url, method ) { | ||
if ( typeof url === 'object' && url.contentType ) { | ||
@@ -338,3 +338,3 @@ var acceptableType = url.contentType === 'application/x-www-form-urlencoded' || | ||
} | ||
return 'application/json'; | ||
return method === "GET" ? "application/x-www-form-urlencoded" : "application/json"; | ||
}; | ||
@@ -365,11 +365,4 @@ | ||
params.url = string.sub(params.url, params.data, true); | ||
params.contentType = contentType; | ||
// Default to JSON encoding, if contentType is not form-urlencoded | ||
var encodeJSON = contentType !== 'application/x-www-form-urlencoded' && | ||
(type && (type === 'POST' || type === 'PUT')); | ||
if (encodeJSON) { | ||
params.data = JSON.stringify(params.data); | ||
params.contentType = contentType; | ||
} | ||
if(reqOptions.includeData === false) { | ||
@@ -376,0 +369,0 @@ delete params.data; |
{ | ||
"name": "can-connect", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Data connection middleware and utilities", | ||
@@ -20,3 +20,3 @@ "main": "can-connect.js", | ||
"can-types": "^1.0.0", | ||
"can-util": "^3.7.0", | ||
"can-util": "^3.8.5", | ||
"can-validate-interface": "0.1.0", | ||
@@ -23,0 +23,0 @@ "can-view-callbacks": "^3.0.2", |
13364
507682
145
Updatedcan-util@^3.8.5