Merge pull request #261 from jo/update-request
Update request
diff --git a/lib/nano.js b/lib/nano.js
index 6aeadd2..e957594 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -100,14 +100,12 @@
if (opts.path) {
req.uri += '/' + opts.path;
- }
- else if (opts.doc) {
- // http://wiki.apache.org/couchdb/HTTP_Document_API#Naming.2FAddressing
+ } else if (opts.doc) {
if (!/^_design/.test(opts.doc)) {
+ // http://wiki.apache.org/couchdb/HTTP_Document_API#Naming.2FAddressing
req.uri += '/' + encodeURIComponent(opts.doc);
- }
- // http://wiki.apache.org/couchdb/HTTP_Document_API#Document_IDs
- else {
+ } else {
+ // http://wiki.apache.org/couchdb/HTTP_Document_API#Document_IDs
req.uri += '/' + opts.doc;
}
@@ -148,8 +146,7 @@
if (opts.body) {
if (Buffer.isBuffer(opts.body) || opts.dontStringify) {
req.body = opts.body;
- }
- else {
+ } else {
req.body = JSON.stringify(opts.body, function(key, value) {
// don't encode functions
if (typeof(value) === 'function') {
diff --git a/package.json b/package.json
index 48935c2..f4ffa12 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"database"
],
"dependencies": {
- "request": "2.46.0",
+ "request": "^2.53.0",
"follow": "^0.11.4",
"errs": "^0.3.0",
"underscore": "^1.7.0",
diff --git a/tests/integration/shared/updates.js b/tests/integration/shared/updates.js
index 8bbff78..54710e1 100644
--- a/tests/integration/shared/updates.js
+++ b/tests/integration/shared/updates.js
@@ -15,18 +15,17 @@
}
called = true;
- //
- // older couches
- //
if (err && updates.error && updates.error === 'illegal_database_name') {
+ //
+ // older couches
+ //
assert.expect(1);
assert.ok(updates.ok, 'db updates are not supported');
assert.end();
- }
- //
- // new couches
- //
- else {
+ } else {
+ //
+ // new couches
+ //
assert.equal(err, null, 'got root');
assert.ok(updates.ok, 'updates are ok');
assert.equal(updates.type, 'created', 'update was a create');