ampersand-sync
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -35,2 +35,9 @@ var _ = require('underscore'); | ||
// If passed a data param, we add it to the URL or body depending on request type | ||
if (options.data && type === 'GET') { | ||
// make sure we've got a '?' | ||
params.url += _.contains(params.url, '?') ? '&' : '?'; | ||
params.url += qs.stringify(options.data); | ||
} | ||
// For older servers, emulate JSON by encoding the request into an HTML-form. | ||
@@ -37,0 +44,0 @@ if (options.emulateJSON) { |
{ | ||
"name": "ampersand-sync", | ||
"description": "Standalone, modern-browser-only version of Backbone.Sync as Common JS module.", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -48,6 +48,9 @@ var test = require('tape'); | ||
test('passing data', function (t) { | ||
// on reads it should be part of the URL | ||
var xhr = sync('read', getStub(), {data: {a: 'a', one: 1}}); | ||
t.equal(xhr.ajaxSettings.url, '/library'); | ||
t.equal(xhr.ajaxSettings.data.a, 'a'); | ||
t.equal(xhr.ajaxSettings.data.one, 1); | ||
t.equal(xhr.ajaxSettings.url, '/library?a=a&one=1', 'data passed to reads should be made into a query string'); | ||
var otherStub = getStub(); | ||
otherStub.url = '/library?something=hi'; | ||
var xhr2 = sync('read', otherStub, {data: {a: 'a', one: 1}}); | ||
t.equal(xhr2.ajaxSettings.url, '/library?something=hi&a=a&one=1', 'data passed to reads should be made into a query string'); | ||
t.end(); | ||
@@ -54,0 +57,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12425
276
0