Skip to content

Commit

Permalink
Properly escape partition ID's
Browse files Browse the repository at this point in the history
This fixes issue apache#283.

However, this is a breaking change, for reasons descibed in that bug report.
  • Loading branch information
swansontec committed Nov 18, 2021
1 parent 2d4bd71 commit f049c12
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/nano.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ module.exports = exports = function dbScope (cfg) {

return relax({
db: dbName,
path: '_partition/' + partitionKey
path: '_partition/' + encodeURIComponent(partitionKey)
}, callback)
}

Expand All @@ -1047,15 +1047,15 @@ module.exports = exports = function dbScope (cfg) {
}
return relax({
db: dbName,
path: '_partition/' + partitionKey + '/_all_docs',
path: '_partition/' + encodeURIComponent(partitionKey) + '/_all_docs',
qs: opts
}, callback)
}

function partitionedListAsStream (partitionKey, qs) {
return relax({
db: dbName,
path: '_partition/' + partitionKey + '/_all_docs',
path: '_partition/' + encodeURIComponent(partitionKey) + '/_all_docs',
qs: qs,
stream: true
})
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -1090,15 +1090,15 @@ 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)
}

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
})
Expand All @@ -1110,15 +1110,15 @@ 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)
}

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
})
Expand Down

0 comments on commit f049c12

Please sign in to comment.