diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js index a8e2f1cd6..eac2d4e35 100644 --- a/packages/bruno-lang/v2/src/jsonToBru.js +++ b/packages/bruno-lang/v2/src/jsonToBru.js @@ -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') diff --git a/packages/bruno-lang/v2/tests/fixtures/request.bru b/packages/bruno-lang/v2/tests/fixtures/request.bru index 058297c36..9cbb45837 100644 --- a/packages/bruno-lang/v2/tests/fixtures/request.bru +++ b/packages/bruno-lang/v2/tests/fixtures/request.bru @@ -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 { diff --git a/packages/bruno-lang/v2/tests/fixtures/request.json b/packages/bruno-lang/v2/tests/fixtures/request.json index 9c6ea5bcf..08520b324 100644 --- a/packages/bruno-lang/v2/tests/fixtures/request.json +++ b/packages/bruno-lang/v2/tests/fixtures/request.json @@ -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" } ] },