diff --git a/packages/bruno-electron/src/utils/filesystem.js b/packages/bruno-electron/src/utils/filesystem.js index 967f088a..60adc913 100644 --- a/packages/bruno-electron/src/utils/filesystem.js +++ b/packages/bruno-electron/src/utils/filesystem.js @@ -122,7 +122,7 @@ const browseFile = async (win, filters) => { filters }); - if(!filePaths) { + if (!filePaths || filePaths[0] === undefined) { return null; } diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 08e4332c..1657c6d2 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -24,7 +24,7 @@ const { outdentString } = require('../../v1/src/utils'); const grammar = ohm.grammar(`Bru { BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | docs)* auths = authawsv4 | authbasic | authbearer | authdigest | authOAuth2 - bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body + bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | bodyrawfile | body bodyforms = bodyformurlencoded | bodymultipart params = paramspath | paramsquery @@ -93,6 +93,7 @@ const grammar = ohm.grammar(`Bru { bodyjson = "body:json" st* "{" nl* textblock tagend bodytext = "body:text" st* "{" nl* textblock tagend bodyxml = "body:xml" st* "{" nl* textblock tagend + bodyrawfile = "body:raw-file" st* "{" nl* textblock tagend bodysparql = "body:sparql" st* "{" nl* textblock tagend bodygraphql = "body:graphql" st* "{" nl* textblock tagend bodygraphqlvars = "body:graphql:vars" st* "{" nl* textblock tagend @@ -528,6 +529,13 @@ const sem = grammar.createSemantics().addAttribute('ast', { } }; }, + bodyrawfile(_1, _2, _3, _4, textblock, _5) { + return { + body: { + rawFile: outdentString(textblock.sourceString) + } + }; + }, bodysparql(_1, _2, _3, _4, textblock, _5) { return { body: { diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js index 4b6e6b96..29f46992 100644 --- a/packages/bruno-lang/v2/src/jsonToBru.js +++ b/packages/bruno-lang/v2/src/jsonToBru.js @@ -229,6 +229,14 @@ ${indentString(body.xml)} ${indentString(body.sparql)} } +`; + } + + if (body && body.rawFile && body.rawFile.length) { + bru += `body:raw-file { +${indentString(body.rawFile)} +} + `; }