Skip to content

Commit

Permalink
dont serialize null values (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Jun 24, 2023
1 parent a9eab58 commit 97a9c12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ function serializeHeaders (response) {
const headerValue = headers[headerName]
if (Array.isArray(headerValue)) {
headers[headerName] = headerValue.map(value => '' + value)
} else if (headerValue === null || headerValue === undefined) {
delete headers[headerName]
} else {
headers[headerName] = '' + headerValue
}
Expand Down
1 change: 0 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,6 @@ test('correctly handles no string headers', (t) => {
t.strictSame(res.headers, {
integer: '12',
float: '3.14',
null: 'null',
string: 'string',
object: '[object Object]',
array: ['1', 'two', '3'],
Expand Down

0 comments on commit 97a9c12

Please sign in to comment.