mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 20:55:41 +00:00
chore: Update Bruno grammar and tests to support keys with spaces, braces, and nested escaped quotes in headers and query parameters
This commit is contained in:
@@ -50,7 +50,7 @@ const grammar = ohm.grammar(`Bru {
|
||||
esc_quote_char = esc_char quote_char
|
||||
quoted_key_char = ~(quote_char | esc_quote_char | nl) any
|
||||
quoted_key = disable_char? quote_char (esc_quote_char | quoted_key_char)* quote_char
|
||||
key = keychar+
|
||||
key = keychar*
|
||||
value = multilinetextblock | valuechar*
|
||||
|
||||
// Dictionary for Assert Block
|
||||
|
||||
@@ -81,6 +81,25 @@ headers {
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse single header with empty key', () => {
|
||||
const input = `
|
||||
headers {
|
||||
: world
|
||||
}`;
|
||||
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
headers: [
|
||||
{
|
||||
name: '',
|
||||
value: 'world',
|
||||
enabled: true
|
||||
}
|
||||
]
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse multi headers', () => {
|
||||
const input = `
|
||||
headers {
|
||||
|
||||
@@ -13,8 +13,10 @@ get {
|
||||
params:query {
|
||||
apiKey: secret
|
||||
numbers: 998877665
|
||||
"key with spaces": is allowed
|
||||
"colon:parameter": is allowed
|
||||
"nested escaped \"quote\"": is allowed
|
||||
"{braces}": is allowed
|
||||
~"disabled:colon:parameter": is allowed
|
||||
~message: hello
|
||||
}
|
||||
@@ -26,6 +28,11 @@ params:path {
|
||||
headers {
|
||||
content-type: application/json
|
||||
Authorization: Bearer 123
|
||||
"key with spaces": is allowed
|
||||
"colon:header": is allowed
|
||||
"{braces}": is allowed
|
||||
"nested escaped \"quote\"": is allowed
|
||||
~"disabled:colon:header": is allowed
|
||||
~transaction-id: {{transactionId}}
|
||||
}
|
||||
|
||||
@@ -96,7 +103,10 @@ body:sparql {
|
||||
body:form-urlencoded {
|
||||
apikey: secret
|
||||
numbers: +91998877665
|
||||
"key with spaces": is allowed
|
||||
"colon:parameter": is allowed
|
||||
"nested escaped \"quote\"": is allowed
|
||||
"{braces}": is allowed
|
||||
~message: hello
|
||||
~"disabled colon:parameter": is allowed
|
||||
}
|
||||
@@ -104,7 +114,10 @@ body:form-urlencoded {
|
||||
body:multipart-form {
|
||||
apikey: secret
|
||||
numbers: +91998877665
|
||||
"key with spaces": is allowed
|
||||
"colon:part": is allowed
|
||||
"nested escaped \"quote\"": is allowed
|
||||
"{braces}": is allowed
|
||||
~message: hello
|
||||
~"disabled colon:part": is allowed
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
"type": "query",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "key with spaces",
|
||||
"value": "is allowed",
|
||||
"type": "query",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name" : "colon:parameter",
|
||||
"value" : "is allowed",
|
||||
@@ -35,6 +41,12 @@
|
||||
"type": "query",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "{braces}",
|
||||
"value": "is allowed",
|
||||
"type": "query",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name" : "disabled:colon:parameter",
|
||||
"value" : "is allowed",
|
||||
@@ -65,6 +77,31 @@
|
||||
"value": "Bearer 123",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "key with spaces",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "colon:header",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "{braces}",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "nested escaped \"quote\"",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "disabled:colon:header",
|
||||
"value": "is allowed",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"name": "transaction-id",
|
||||
"value": "{{transactionId}}",
|
||||
@@ -127,11 +164,26 @@
|
||||
"value": "+91998877665",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "key with spaces",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "colon:parameter",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "nested escaped \"quote\"",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "{braces}",
|
||||
"value": "is allowed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"value": "hello",
|
||||
@@ -158,6 +210,13 @@
|
||||
"enabled": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"contentType": "",
|
||||
"name": "key with spaces",
|
||||
"value": "is allowed",
|
||||
"enabled": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"contentType": "",
|
||||
"name": "colon:part",
|
||||
@@ -165,6 +224,20 @@
|
||||
"enabled": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"contentType": "",
|
||||
"name": "nested escaped \"quote\"",
|
||||
"value": "is allowed",
|
||||
"enabled": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"contentType": "",
|
||||
"name": "{braces}",
|
||||
"value": "is allowed",
|
||||
"enabled": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"contentType": "",
|
||||
"name": "message",
|
||||
|
||||
Reference in New Issue
Block a user