File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
web/app/components/workflow/nodes/http/components Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,14 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str
22
22
const node : Partial < HttpNodeType > = {
23
23
title : 'HTTP Request' ,
24
24
desc : 'Imported from cURL' ,
25
- method : Method . get ,
25
+ method : undefined ,
26
26
url : '' ,
27
27
headers : '' ,
28
28
params : '' ,
29
29
body : { type : BodyType . none , data : '' } ,
30
30
}
31
31
const args = curlCommand . match ( / (?: [ ^ \s " ' ] + | " [ ^ " ] * " | ' [ ^ ' ] * ' ) + / g) || [ ]
32
+ let hasData = false
32
33
33
34
for ( let i = 1 ; i < args . length ; i ++ ) {
34
35
const arg = args [ i ] . replace ( / ^ [ ' " ] | [ ' " ] $ / g, '' )
@@ -38,6 +39,7 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str
38
39
if ( i + 1 >= args . length )
39
40
return { node : null , error : 'Missing HTTP method after -X or --request.' }
40
41
node . method = ( args [ ++ i ] . replace ( / ^ [ ' " ] | [ ' " ] $ / g, '' ) as Method ) || Method . get
42
+ hasData = true
41
43
break
42
44
case '-H' :
43
45
case '--header' :
@@ -89,6 +91,9 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str
89
91
}
90
92
}
91
93
94
+ // Determine final method
95
+ node . method = node . method || ( hasData ? Method . post : Method . get )
96
+
92
97
if ( ! node . url )
93
98
return { node : null , error : 'Missing URL or url not start with http.' }
94
99
You can’t perform that action at this time.
0 commit comments