@@ -14,12 +14,13 @@ self = module.exports = {
14
14
}
15
15
options = sanitizeOptions ( options , self . getOptions ( ) ) ;
16
16
17
- var indent , trim , headersData , body , redirect , timeout , multiLine ,
17
+ var indent , trim , headersData , body , redirect , timeout , multiLine , bodySingleLine ,
18
18
format , snippet , silent , url , quoteType ;
19
19
20
20
redirect = options . followRedirect ;
21
21
timeout = options . requestTimeoutInSeconds ;
22
22
multiLine = options . multiLine ;
23
+ bodySingleLine = options . bodySingleLine ;
23
24
format = options . longFormat ;
24
25
trim = options . trimRequestBody ;
25
26
silent = options . silent ;
@@ -136,7 +137,12 @@ self = module.exports = {
136
137
} ) ;
137
138
break ;
138
139
case 'raw' :
139
- snippet += indent + `--data-raw ${ quoteType } ${ sanitize ( body . raw . toString ( ) , trim , quoteType ) } ${ quoteType } ` ;
140
+ // remove newlines from body when bodySingleLine is true
141
+ if ( bodySingleLine ) {
142
+ snippet += indent + `--data-raw ${ quoteType } ${ sanitize ( body . raw . toString ( ) , trim , quoteType ) . replace ( / \n / g, "" ) } ${ quoteType } ` ;
143
+ } else {
144
+ snippet += indent + `--data-raw ${ quoteType } ${ sanitize ( body . raw . toString ( ) , trim , quoteType ) } ${ quoteType } ` ;
145
+ }
140
146
break ;
141
147
142
148
case 'graphql' :
@@ -196,6 +202,13 @@ self = module.exports = {
196
202
default : true ,
197
203
description : 'Split cURL command across multiple lines'
198
204
} ,
205
+ {
206
+ name : 'Generate single line body' ,
207
+ id : 'bodySingleLine' ,
208
+ type : 'boolean' ,
209
+ default : false ,
210
+ description : 'Removes every new line character from body to make the whole cURL command trully one line'
211
+ } ,
199
212
{
200
213
name : 'Use long form options' ,
201
214
id : 'longFormat' ,
0 commit comments