Skip to content

Commit

Permalink
Merge pull request #144 from balena-io-modules/fix-build-qs
Browse files Browse the repository at this point in the history
Correctly exclude a few keys from being JSON encoded
  • Loading branch information
apocas committed Jun 3, 2022
2 parents 7d52be9 + a391df4 commit 301592d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,13 @@ Modem.prototype.followProgress = function (stream, onFinished, onProgress) {
Modem.prototype.buildQuerystring = function (opts) {
var clone = {};

// serialize map values as JSON strings, else querystring truncates.
// 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'
&& !Array.isArray(opts[key])
// Ref: https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild
// > cachefrom (string) JSON array of images used for build cache resolution.
|| key === 'cachefrom'
&& !['t', 'extrahosts'].includes(key)
) {
clone[key] = JSON.stringify(opts[key]);
} else {
Expand Down

0 comments on commit 301592d

Please sign in to comment.