Skip to content

Commit 911ab77

Browse files
authored
Fix crash when building nsurlsession snippets for empty params (Kong#295)
1 parent 1dda869 commit 911ab77

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/targets/objc/nsurlsession/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const nsurlsession: Client<NsurlsessionOptions> = {
5353

5454
switch (postData.mimeType) {
5555
case 'application/x-www-form-urlencoded':
56-
if (postData.params) {
56+
if (postData.params?.length) {
5757
// By appending parameters one by one in the resulting snippet,
5858
// we make it easier for the user to edit it according to his or her needs after pasting.
5959
// The user can just add/remove lines adding/removing body parameters.

src/targets/swift/nsurlsession/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const nsurlsession: Client<NsurlsessionOptions> = {
5858
// we make it easier for the user to edit it according to his or her needs after pasting.
5959
// The user can just add/remove lines adding/removing body parameters.
6060
blank();
61-
if (postData.params) {
61+
if (postData.params?.length) {
6262
const [head, ...tail] = postData.params;
6363
push(
6464
`let postData = NSMutableData(data: "${head.name}=${head.value}".data(using: String.Encoding.utf8)!)`,

0 commit comments

Comments
 (0)