mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-26 23:11:32 +02:00
fix: support parsing of empty urls in bru files
This commit is contained in:
parent
fff540010e
commit
405b50edcd
@ -1,14 +1,14 @@
|
|||||||
const {
|
const {
|
||||||
sequenceOf,
|
sequenceOf,
|
||||||
whitespace,
|
|
||||||
str,
|
str,
|
||||||
lookAhead,
|
regex,
|
||||||
choice,
|
choice,
|
||||||
endOfInput,
|
endOfInput,
|
||||||
everyCharUntil
|
everyCharUntil
|
||||||
} = require("arcsecond");
|
} = require("arcsecond");
|
||||||
|
|
||||||
const newline = lookAhead(str("\n"));
|
const whitespace = regex(/^[ \t]*/)
|
||||||
|
const newline = regex(/^\r?\n/);
|
||||||
const newLineOrEndOfInput = choice([endOfInput, newline]);
|
const newLineOrEndOfInput = choice([endOfInput, newline]);
|
||||||
|
|
||||||
const inlineTag = sequenceOf([
|
const inlineTag = sequenceOf([
|
||||||
@ -21,8 +21,15 @@ const inlineTag = sequenceOf([
|
|||||||
str('body-mode')
|
str('body-mode')
|
||||||
]),
|
]),
|
||||||
whitespace,
|
whitespace,
|
||||||
everyCharUntil(newLineOrEndOfInput)
|
choice([
|
||||||
|
newline,
|
||||||
|
everyCharUntil(newLineOrEndOfInput)
|
||||||
|
])
|
||||||
]).map(([key, _, val]) => {
|
]).map(([key, _, val]) => {
|
||||||
|
if(val === '\n' || val === '\r\n') {
|
||||||
|
val = '';
|
||||||
|
}
|
||||||
|
|
||||||
if(key === 'body-mode') {
|
if(key === 'body-mode') {
|
||||||
return {
|
return {
|
||||||
body: {
|
body: {
|
||||||
|
@ -89,4 +89,29 @@ describe('bruToJson', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('jsonToBru - should parse bru file having empty url', () => {
|
||||||
|
const requestFile = `name Send Bulk SMS
|
||||||
|
method GET
|
||||||
|
url
|
||||||
|
type http-request
|
||||||
|
body-mode none
|
||||||
|
seq 1
|
||||||
|
`;
|
||||||
|
|
||||||
|
it('should parse .bru file having empty url', () => {
|
||||||
|
const result = bruToJson(requestFile);
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
type: 'http-request',
|
||||||
|
name: 'Send Bulk SMS',
|
||||||
|
seq: 1,
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
url: '',
|
||||||
|
params: [],
|
||||||
|
headers: [],
|
||||||
|
body: { mode: 'none' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user