mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
feat: deprecated form-url-encoded in favour of form-urlencoded in body type in bru lang
This commit is contained in:
parent
84ce75263b
commit
0c42298ce6
@ -55,10 +55,8 @@ script
|
||||
/script
|
||||
|
||||
assert
|
||||
{
|
||||
"$res.data.order.items.length": 1,
|
||||
"$res.data.orderNumber.isDefined": true
|
||||
}
|
||||
1 $res.data.order.items.length 1
|
||||
1 $res.data.orderNumber.isDefined true
|
||||
/assert
|
||||
|
||||
docs
|
||||
|
@ -85,8 +85,22 @@ const line = sequenceOf([
|
||||
const lines = many(line);
|
||||
const keyvalLines = sepBy(newline)(lines);
|
||||
|
||||
|
||||
/**
|
||||
* We have deprecated form-url-encoded type in body tag, it was a misspelling on my part
|
||||
* The new type is form-urlencoded
|
||||
*
|
||||
* Very few peope would have used this. I launched this to the public on 22 Jan 2023
|
||||
* And I am making the change on 23 Jan 2023
|
||||
*
|
||||
* This deprecated tag can be removed on 1 April 2023
|
||||
*/
|
||||
|
||||
// body(type=form-url-encoded)
|
||||
const bodyFormUrlEncoded = regex(/^body\s*\(\s*type\s*=\s*form-url-encoded\s*\)\s*\r?\n/);
|
||||
const bodyFormUrlEncodedDeprecated = regex(/^body\s*\(\s*type\s*=\s*form-url-encoded\s*\)\s*\r?\n/);
|
||||
|
||||
// body(type=form-urlencoded)
|
||||
const bodyFormUrlEncoded = regex(/^body\s*\(\s*type\s*=\s*form-urlencoded\s*\)\s*\r?\n/);
|
||||
|
||||
// body(type=multipart-form)
|
||||
const bodyMultipartForm = regex(/^body\s*\(\s*type\s*=\s*multipart-form\s*\)\s*\r?\n/);
|
||||
@ -96,6 +110,14 @@ const bodyMultipartForm = regex(/^body\s*\(\s*type\s*=\s*multipart-form\s*\)\s*\
|
||||
// todo: fix this
|
||||
const bodyEndRelaxed = regex(/^[\r?\n]*\/body\s*[\r?\n]*/);
|
||||
|
||||
const bodyFormUrlEncodedTagDeprecated = between(bodyFormUrlEncodedDeprecated)(bodyEndRelaxed)(keyvalLines).map(([result]) => {
|
||||
return {
|
||||
body: {
|
||||
formUrlEncoded: result
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const bodyFormUrlEncodedTag = between(bodyFormUrlEncoded)(bodyEndRelaxed)(keyvalLines).map(([result]) => {
|
||||
return {
|
||||
body: {
|
||||
@ -117,6 +139,7 @@ module.exports = {
|
||||
bodyGraphqlTag,
|
||||
bodyTextTag,
|
||||
bodyXmlTag,
|
||||
bodyFormUrlEncodedTagDeprecated,
|
||||
bodyFormUrlEncodedTag,
|
||||
bodyMultipartFormTag
|
||||
};
|
||||
|
@ -18,6 +18,7 @@ const {
|
||||
bodyGraphqlTag,
|
||||
bodyTextTag,
|
||||
bodyXmlTag,
|
||||
bodyFormUrlEncodedTagDeprecated,
|
||||
bodyFormUrlEncodedTag,
|
||||
bodyMultipartFormTag
|
||||
} = require('./body-tag');
|
||||
@ -33,6 +34,7 @@ const bruToJson = (fileContents) => {
|
||||
bodyGraphqlTag,
|
||||
bodyTextTag,
|
||||
bodyXmlTag,
|
||||
bodyFormUrlEncodedTagDeprecated,
|
||||
bodyFormUrlEncodedTag,
|
||||
bodyMultipartFormTag,
|
||||
scriptTag,
|
||||
@ -155,7 +157,7 @@ ${indentString(body.xml)}
|
||||
|
||||
if(body && body.formUrlEncoded && body.formUrlEncoded.length) {
|
||||
bru += `
|
||||
body(type=form-url-encoded)
|
||||
body(type=form-urlencoded)
|
||||
${body.formUrlEncoded.map(item => ` ${item.enabled ? 1 : 0} ${item.name} ${item.value}`).join('\n')}
|
||||
/body
|
||||
`;
|
||||
|
@ -40,7 +40,7 @@ body(type=xml)
|
||||
<body>back to the ice age</body>
|
||||
/body
|
||||
|
||||
body(type=form-url-encoded)
|
||||
body(type=form-urlencoded)
|
||||
1 username john
|
||||
0 password {{password}}
|
||||
/body
|
||||
|
Loading…
Reference in New Issue
Block a user