From f049c1244235acfe3c1e238398b04fa49c5837a8 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Thu, 18 Nov 2021 13:24:50 -0800 Subject: [PATCH] Properly escape partition ID's This fixes issue #283. However, this is a breaking change, for reasons descibed in that bug report. --- lib/nano.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/nano.js b/lib/nano.js index 0b819ea..969248f 100644 --- a/lib/nano.js +++ b/lib/nano.js @@ -1036,7 +1036,7 @@ module.exports = exports = function dbScope (cfg) { return relax({ db: dbName, - path: '_partition/' + partitionKey + path: '_partition/' + encodeURIComponent(partitionKey) }, callback) } @@ -1047,7 +1047,7 @@ module.exports = exports = function dbScope (cfg) { } return relax({ db: dbName, - path: '_partition/' + partitionKey + '/_all_docs', + path: '_partition/' + encodeURIComponent(partitionKey) + '/_all_docs', qs: opts }, callback) } @@ -1055,7 +1055,7 @@ module.exports = exports = function dbScope (cfg) { function partitionedListAsStream (partitionKey, qs) { return relax({ db: dbName, - path: '_partition/' + partitionKey + '/_all_docs', + path: '_partition/' + encodeURIComponent(partitionKey) + '/_all_docs', qs: qs, stream: true }) @@ -1068,7 +1068,7 @@ module.exports = exports = function dbScope (cfg) { return relax({ db: dbName, - path: '_partition/' + partition + '/_find', + path: '_partition/' + encodeURIComponent(partition) + '/_find', method: 'POST', body: query }, callback) @@ -1077,7 +1077,7 @@ module.exports = exports = function dbScope (cfg) { function partitionedFindAsStream (partition, query) { return relax({ db: dbName, - path: '_partition/' + partition + '/_find', + path: '_partition/' + encodeURIComponent(partition) + '/_find', method: 'POST', body: query, stream: true @@ -1090,7 +1090,7 @@ module.exports = exports = function dbScope (cfg) { } return relax({ db: dbName, - path: '_partition/' + partition + '/_design/' + ddoc + '/_search/' + searchName, + path: '_partition/' + encodeURIComponent(partition) + '/_design/' + ddoc + '/_search/' + searchName, qs: opts }, callback) } @@ -1098,7 +1098,7 @@ module.exports = exports = function dbScope (cfg) { function partitionedSearchAsStream (partition, ddoc, searchName, opts) { return relax({ db: dbName, - path: '_partition/' + partition + '/_design/' + ddoc + '/_search/' + searchName, + path: '_partition/' + encodeURIComponent(partition) + '/_design/' + ddoc + '/_search/' + searchName, qs: opts, stream: true }) @@ -1110,7 +1110,7 @@ module.exports = exports = function dbScope (cfg) { } return relax({ db: dbName, - path: '_partition/' + partition + '/_design/' + ddoc + '/_view/' + viewName, + path: '_partition/' + encodeURIComponent(partition) + '/_design/' + ddoc + '/_view/' + viewName, qs: opts }, callback) } @@ -1118,7 +1118,7 @@ module.exports = exports = function dbScope (cfg) { function partitionedViewAsStream (partition, ddoc, viewName, opts) { return relax({ db: dbName, - path: '_partition/' + partition + '/_design/' + ddoc + '/_view/' + viewName, + path: '_partition/' + encodeURIComponent(partition) + '/_design/' + ddoc + '/_view/' + viewName, qs: opts, stream: true })