From 98b45a2fd4a566f21271296d40278912d9ce76f3 Mon Sep 17 00:00:00 2001 From: Graham White Date: Tue, 5 Dec 2023 17:22:56 +0000 Subject: [PATCH] refactor: protocol regex matches axios Since axios is used for requests, it makes sense to match the protocol parsing with their code at https://github.com/axios/axios/blob/main/lib/helpers/parseProtocol.js Closes: #1152 Signed-off-by: Graham White --- packages/bruno-cli/src/runner/run-single-request.js | 2 +- packages/bruno-electron/src/ipc/network/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bruno-cli/src/runner/run-single-request.js b/packages/bruno-cli/src/runner/run-single-request.js index 50a30144a..9b12e86a2 100644 --- a/packages/bruno-cli/src/runner/run-single-request.js +++ b/packages/bruno-cli/src/runner/run-single-request.js @@ -17,7 +17,7 @@ const { SocksProxyAgent } = require('socks-proxy-agent'); const { makeAxiosInstance } = require('../utils/axios-instance'); const { shouldUseProxy, PatchedHttpsProxyAgent } = require('../utils/proxy-util'); -const protocolRegex = /([a-zA-Z]{2,20}:\/\/)(.*)/; +const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/; const runSingleRequest = async function ( filename, diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index b11955823..c4577bf3d 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -72,7 +72,7 @@ const getEnvVars = (environment = {}) => { }; }; -const protocolRegex = /([a-zA-Z]{2,20}:\/\/)(.*)/; +const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/; const configureRequest = async ( collectionUid,