From 4a986184d739c62c028488c7fed6fd6fdc64f262 Mon Sep 17 00:00:00 2001 From: Luca Zambarda Date: Tue, 6 Sep 2016 12:43:08 +0200 Subject: [PATCH] Update nano.js I found that encoding a string causes the JSON to be malformed with some calls (it encoded "created_at" into "\"created_at\"" and caused my DB to throw a 400 error). Thus I believe that only objects parameters must be encoded. --- lib/nano.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/nano.js b/lib/nano.js index 81d12d78..6a0198a2 100644 --- a/lib/nano.js +++ b/lib/nano.js @@ -511,7 +511,10 @@ module.exports = exports = nano = function dbScope(cfg) { var paramsToEncode = ['counts', 'drilldown', 'group_sort', 'ranges', 'sort']; paramsToEncode.forEach(function(param) { if (param in qs) { - qs[param] = JSON.stringify(qs[param]); + // Don't encode strings as this could lead to have too many quotes + if (typeof qs[param] === 'object') { + qs[param] = JSON.stringify(qs[param]); + } } });