Pārlūkot izejas kodu

fix: set method to POST when body exists (#14523) (#14524)

tags/1.0.0
Jiakaic pirms 8 mēnešiem
vecāks
revīzija
be18b103b7
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 6
- 1
web/app/components/workflow/nodes/http/components/curl-panel.tsx Parādīt failu

const node: Partial<HttpNodeType> = { const node: Partial<HttpNodeType> = {
title: 'HTTP Request', title: 'HTTP Request',
desc: 'Imported from cURL', desc: 'Imported from cURL',
method: Method.get,
method: undefined,
url: '', url: '',
headers: '', headers: '',
params: '', params: '',
body: { type: BodyType.none, data: '' }, body: { type: BodyType.none, data: '' },
} }
const args = curlCommand.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || [] const args = curlCommand.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || []
let hasData = false


for (let i = 1; i < args.length; i++) { for (let i = 1; i < args.length; i++) {
const arg = args[i].replace(/^['"]|['"]$/g, '') const arg = args[i].replace(/^['"]|['"]$/g, '')
if (i + 1 >= args.length) if (i + 1 >= args.length)
return { node: null, error: 'Missing HTTP method after -X or --request.' } return { node: null, error: 'Missing HTTP method after -X or --request.' }
node.method = (args[++i].replace(/^['"]|['"]$/g, '') as Method) || Method.get node.method = (args[++i].replace(/^['"]|['"]$/g, '') as Method) || Method.get
hasData = true
break break
case '-H': case '-H':
case '--header': case '--header':
} }
} }


// Determine final method
node.method = node.method || (hasData ? Method.post : Method.get)

if (!node.url) if (!node.url)
return { node: null, error: 'Missing URL or url not start with http.' } return { node: null, error: 'Missing URL or url not start with http.' }



Notiek ielāde…
Atcelt
Saglabāt