From 17ded5de4c6a4dc27e99f7af39d0df98f4ff734f Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:55:23 +0530 Subject: [PATCH] fix: fixed issues with creating patch requests --- .../src/components/Sidebar/NewFolder/index.js | 2 +- .../src/components/Sidebar/NewRequest/index.js | 2 +- packages/bruno-lang/v2/src/bruToJson.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js index f72a4df0f..3f9d8ffd5 100644 --- a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js @@ -25,7 +25,7 @@ const NewFolder = ({ collection, item, onClose }) => { if(item && item.uid) { return true; } - return !(value.trim().toLowerCase().includes('environments')) + return value && !(value.trim().toLowerCase().includes('environments')) } }) }), diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js index f9b173c91..b95d29a38 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js @@ -30,7 +30,7 @@ const NewRequest = ({ collection, item, isEphermal, onClose }) => { .test({ name: 'requestName', message: 'The request name "index" is reserved in bruno', - test: value => !(value.trim().toLowerCase().includes('index')), + test: value => value && !(value.trim().toLowerCase().includes('index')), }) }), onSubmit: (values) => { diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 6ff564fbf..d7835fcf4 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -57,11 +57,12 @@ const grammar = ohm.grammar(`Bru { meta = "meta" dictionary - http = get | post | put | delete | options | head | connect | trace + http = get | post | put | delete | patch | options | head | connect | trace get = "get" dictionary post = "post" dictionary put = "put" dictionary delete = "delete" dictionary + patch = "patch" dictionary options = "options" dictionary head = "head" dictionary connect = "connect" dictionary @@ -237,6 +238,14 @@ const sem = grammar.createSemantics().addAttribute('ast', { } }; }, + patch(_1, dictionary) { + return { + http: { + method: 'patch', + ...mapPairListToKeyValPair(dictionary.ast) + } + }; + }, options(_1, dictionary) { return { http: {