diff --git a/packages/bruno-lang/example/request.next.bru b/packages/bruno-lang/example/request.next.bru index 168e0def..2d6c30b6 100644 --- a/packages/bruno-lang/example/request.next.bru +++ b/packages/bruno-lang/example/request.next.bru @@ -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 diff --git a/packages/bruno-lang/src/body-tag.js b/packages/bruno-lang/src/body-tag.js index 2810e086..5a79dfae 100644 --- a/packages/bruno-lang/src/body-tag.js +++ b/packages/bruno-lang/src/body-tag.js @@ -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 }; diff --git a/packages/bruno-lang/src/index.js b/packages/bruno-lang/src/index.js index 1aa0ecd0..71511c36 100644 --- a/packages/bruno-lang/src/index.js +++ b/packages/bruno-lang/src/index.js @@ -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 `; diff --git a/packages/bruno-lang/tests/fixtures/request.bru b/packages/bruno-lang/tests/fixtures/request.bru index ee6d89ef..a96dcef2 100644 --- a/packages/bruno-lang/tests/fixtures/request.bru +++ b/packages/bruno-lang/tests/fixtures/request.bru @@ -40,7 +40,7 @@ body(type=xml) back to the ice age /body -body(type=form-url-encoded) +body(type=form-urlencoded) 1 username john 0 password {{password}} /body