Skip to content

Commit

Permalink
Merge pull request #181 from Clovel/fix/query-string-arrays
Browse files Browse the repository at this point in the history
[Fixes #180] Allow for root-level arrays to be querystring-ed in Modem.prototype.buildQuerystring
  • Loading branch information
apocas authored Jan 13, 2025
2 parents c95995d + 50f5686 commit f1331a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1,108 deletions.
10 changes: 4 additions & 6 deletions lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,11 @@ Modem.prototype.followProgress = function (streama, onFinished, onProgress) {
Modem.prototype.buildQuerystring = function (opts) {
var clone = {};

// serialize map and array values as JSON strings, else querystring truncates.
// 't' and 'extrahosts' can be arrays but need special treatment so that they're
// passed as multiple qs parameters instead of JSON values.
Object.keys(opts).map(function (key, i) {
if (opts[key]
&& typeof opts[key] === 'object'
&& !['t', 'extrahosts'].includes(key)
if (
opts[key] &&
typeof opts[key] === 'object' &&
!Array.isArray(opts[key])
) {
clone[key] = JSON.stringify(opts[key]);
} else {
Expand Down
Loading

0 comments on commit f1331a0

Please sign in to comment.