fix: unable to set request bodies with colon characters in their names

This commit is contained in:
Mateusz Pietryga 2024-09-23 19:29:51 +02:00
parent d64dffe7fa
commit 3a8922aad9
No known key found for this signature in database
GPG Key ID: 549A107FB8327670
3 changed files with 32 additions and 6 deletions

View File

@ -105,7 +105,7 @@ const jsonToBru = (json) => {
if (enabled(headers).length) {
bru += `\n${indentString(
enabled(headers)
.map((item) => `${item.name}: ${item.value}`)
.map((item) => `${quoteKey(item.name)}: ${item.value}`)
.join('\n')
)}`;
}
@ -113,7 +113,7 @@ const jsonToBru = (json) => {
if (disabled(headers).length) {
bru += `\n${indentString(
disabled(headers)
.map((item) => `~${item.name}: ${item.value}`)
.map((item) => `~${quoteKey(item.name)}: ${item.value}`)
.join('\n')
)}`;
}
@ -260,14 +260,14 @@ ${indentString(body.sparql)}
if (enabled(body.formUrlEncoded).length) {
const enabledValues = enabled(body.formUrlEncoded)
.map((item) => `${item.name}: ${getValueString(item.value)}`)
.map((item) => `${quoteKey(item.name)}: ${getValueString(item.value)}`)
.join('\n');
bru += `${indentString(enabledValues)}\n`;
}
if (disabled(body.formUrlEncoded).length) {
const disabledValues = disabled(body.formUrlEncoded)
.map((item) => `~${item.name}: ${getValueString(item.value)}`)
.map((item) => `~${quoteKey(item.name)}: ${getValueString(item.value)}`)
.join('\n');
bru += `${indentString(disabledValues)}\n`;
}
@ -285,14 +285,14 @@ ${indentString(body.sparql)}
.map((item) => {
const enabled = item.enabled ? '' : '~';
if (item.type === 'text') {
return `${enabled}${item.name}: ${getValueString(item.value)}`;
return `${enabled}${quoteKey(item.name)}: ${getValueString(item.value)}`;
}
if (item.type === 'file') {
let filepaths = item.value || [];
let filestr = filepaths.join('|');
const value = `@file(${filestr})`;
return `${enabled}${item.name}: ${value}`;
return `${enabled}${quoteKey(item.name)}: ${value}`;
}
})
.join('\n')

View File

@ -96,13 +96,17 @@ body:sparql {
body:form-urlencoded {
apikey: secret
numbers: +91998877665
"colon:parameter": is allowed
~message: hello
~"disabled colon:parameter": is allowed
}
body:multipart-form {
apikey: secret
numbers: +91998877665
"colon:part": is allowed
~message: hello
~"disabled colon:part": is allowed
}
body:graphql {

View File

@ -127,10 +127,20 @@
"value": "+91998877665",
"enabled": true
},
{
"name": "colon:parameter",
"value": "is allowed",
"enabled": true
},
{
"name": "message",
"value": "hello",
"enabled": false
},
{
"name": "disabled colon:parameter",
"value": "is allowed",
"enabled": false
}
],
"multipartForm": [
@ -146,11 +156,23 @@
"enabled": true,
"type": "text"
},
{
"name": "colon:part",
"value": "is allowed",
"enabled": true,
"type": "text"
},
{
"name": "message",
"value": "hello",
"enabled": false,
"type": "text"
},
{
"name": "disabled colon:part",
"value": "is allowed",
"enabled": false,
"type": "text"
}
]
},