mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-22 13:48:41 +01:00
feat: bru lang - allow parsing empty header values
This commit is contained in:
parent
a21615a5fb
commit
118ceacf46
@ -12,7 +12,7 @@ const grammar = ohm.grammar(`Bru {
|
||||
headers = "headers" st* "{" pairlist? tagend
|
||||
|
||||
pairlist = nl* pair (~tagend nl pair)* (~tagend space)*
|
||||
pair = st* key st* ":" st* value st*
|
||||
pair = st* key st* ":" st* value? st*
|
||||
key = ~tagend validkey*
|
||||
value = ~tagend validvalue*
|
||||
|
||||
@ -58,7 +58,7 @@ const sem = grammar.createSemantics().addAttribute('ast', {
|
||||
},
|
||||
pair(_1, key, _2, _3, _4, value, _5) {
|
||||
let res = {};
|
||||
res[key.ast] = value.ast;
|
||||
res[key.ast] = _.get(value, 'ast[0]', '');
|
||||
return res;
|
||||
},
|
||||
key(chars) {
|
||||
|
@ -56,6 +56,23 @@ headers {
|
||||
assertSingleHeader(input);
|
||||
});
|
||||
|
||||
it("should parse single header with empty value", () => {
|
||||
const input = `
|
||||
headers {
|
||||
hello:
|
||||
}`;
|
||||
|
||||
const output = bruToJsonV2(input);
|
||||
const expected = {
|
||||
"headers": [{
|
||||
"name": "hello",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
}]
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it("should parse multi headers", () => {
|
||||
const input = `
|
||||
headers {
|
||||
|
Loading…
Reference in New Issue
Block a user