Skip to content

Commit e99422a

Browse files
authored
Fix setting default value of request.PostData of HarEntry (Kong#323)
* fix: prevent override of default value of request.postData when postData might be undefined * chore: optional chaining safety check for when request.PostData can be undefined
1 parent b9e1d7b commit e99422a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/httpsnippet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ export class HTTPSnippet {
100100
cookies: [],
101101
httpVersion: 'HTTP/1.1',
102102
queryString: [],
103-
postData: {
103+
...request,
104+
postData: request?.postData || {
104105
mimeType: request.postData?.mimeType || 'application/octet-stream',
105106
},
106-
...request,
107107
};
108108

109109
if (validateHarRequest(req)) {
@@ -164,7 +164,7 @@ export class HTTPSnippet {
164164
request.allHeaders.cookie = cookies.join('; ');
165165
}
166166

167-
switch (request.postData.mimeType) {
167+
switch (request?.postData.mimeType) {
168168
case 'multipart/mixed':
169169
case 'multipart/related':
170170
case 'multipart/form-data':

0 commit comments

Comments
 (0)