Skip to content

Commit

Permalink
fix(proxy): ignore nulls in transformJsonResponse (#719)
Browse files Browse the repository at this point in the history
* fix(proxy): ignore nulls in transformJsonResponse

* style: fix linting errors

* chore: try run lint
  • Loading branch information
Birkbjo committed Jun 8, 2022
1 parent ede728c commit b72dd79
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/src/lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const transformJsonResponse = (res, { target, baseUrl }) => {
transformJsonResponse(r, { target, baseUrl })
)
}
if (res === null) {
return res
}
return _.transform(
res,
(result, value, key) => {
Expand Down
22 changes: 22 additions & 0 deletions cli/src/lib/proxy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ describe('transformJsonResponse', () => {
'http:https://localhost:8080/api/endpoint'
)
})

it('should not convert nulls to {}', () => {
const transformedResponse = transformJsonResponse(
{
a: {
b: {
c: 'https://play.dhis2.org/dev/api/endpoint',
},
d: null,
},
},
{
target: 'https://play.dhis2.org/dev',
baseUrl: 'http:https://localhost:8080',
}
)

expect(transformedResponse.a.b.c).toBe(
'http:https://localhost:8080/api/endpoint'
)
expect(transformedResponse.a.d).toBe(null)
})
})

describe('rewriteLocation', () => {
Expand Down

0 comments on commit b72dd79

Please sign in to comment.