Skip to content

Commit

Permalink
fix: pin options query string param names
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Jul 6, 2021
1 parent abe1979 commit 1329cec
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ function setAddParams (options, searchParams) {
function setPinOptions (options, searchParams) {
options = options || {}
if (options.replicationFactorMin != null) {
searchParams.set('replication_factor_min', options.replicationFactorMin)
searchParams.set('replication-min', options.replicationFactorMin)
}
if (options.replicationFactorMax != null) {
searchParams.set('replication_factor_max', options.replicationFactorMax)
searchParams.set('replication-max', options.replicationFactorMax)
}
if (options.name != null) {
searchParams.set('name', options.name)
Expand All @@ -293,23 +293,21 @@ function setPinOptions (options, searchParams) {
searchParams.set('mode', options.mode)
}
if (options.shardSize != null) {
searchParams.set('shard_size', options.shardSize)
searchParams.set('shard-size', options.shardSize)
}
if (options.userAllocations != null) {
for (const a of options.userAllocations) {
searchParams.append('user_allocations', a)
}
searchParams.set('user-allocations', options.userAllocations.join(','))
}
if (options.expireAt != null) {
searchParams.set('expire_at', options.expireAt.toISOString())
searchParams.set('expire-at', options.expireAt.toISOString())
}
if (options.metadata != null) {
for (const [k, v] of Object.entries(options.metadata)) {
searchParams.set(`meta-${k}`, v)
}
}
if (options.pinUpdate != null) {
searchParams.set('pin_update', options.pinUpdate)
searchParams.set('pin-update', options.pinUpdate)
}
if (options.origins != null) {
searchParams.set('origins', options.origins.join(','))
Expand Down

0 comments on commit 1329cec

Please sign in to comment.