Skip to content

Commit

Permalink
fix issue with missing query params
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley committed Jun 22, 2023
1 parent 5d743bf commit e968d39
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/common/harvest/harvest.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@ export class Harvest extends SharedContext {
}
return Object.entries(input || {})
.reduce((accumulator, [key, value]) => {
if (value !== null && value !== undefined && value.length) {
if (
value !== null &&
value !== undefined && (
(typeof value === 'number') ||
(typeof value === 'string' && value.length > 0) ||
(Object.entries(value).length > 0)
)
) {
accumulator[key] = value
}

Expand Down
16 changes: 16 additions & 0 deletions src/common/harvest/harvest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,20 @@ describe('cleanPayload', () => {
expect(Object.keys(results.body)).not.toContain('foo')
expect(Object.keys(results.qs)).not.toContain('foo')
})

test.each([
{ [faker.datatype.uuid()]: { [faker.datatype.uuid()]: faker.datatype.number({ min: 100, max: 1000 }) } },
{ [faker.datatype.uuid()]: faker.datatype.number({ min: 100, max: 1000 }) },
{ [faker.datatype.uuid()]: new Uint8Array(faker.datatype.number({ min: 100, max: 1000 })) }
])('should retain %s properties in body and qs', (input) => {
const payload = {
body: input,
qs: input
}

const results = harvestInstance.cleanPayload(payload)

expect(results.body).toEqual(input)
expect(results.qs).toEqual(input)
})
})

0 comments on commit e968d39

Please sign in to comment.