From bb8571da2d432d2abc9130515880a4806946cfac Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 23 Jul 2020 19:46:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=A0=A1=E9=AA=8CURL=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/model/ScenarioModel.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 965b35b0e1..3c3e59e9d5 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -283,10 +283,20 @@ export class HttpRequest extends Request { info: 'api_test.request.input_path' } } - } else if (!this.url) { - return { - isValid: false, - info: 'api_test.request.input_url' + } else { + if (!this.url) { + return { + isValid: false, + info: 'api_test.request.input_url' + } + } + try { + new URL(this.url) + } catch (e) { + return { + isValid: false, + info: 'api_test.request.url_invalid' + } } } return { @@ -631,6 +641,9 @@ class JMXHttpRequest { this.useEnvironment = request.useEnvironment; this.method = request.method; if (!request.useEnvironment) { + if (!request.url.startsWith("http://") && !request.url.startsWith("https://")) { + request.url = 'http://' + request.url; + } let url = new URL(request.url); this.hostname = decodeURIComponent(url.hostname); this.pathname = decodeURIComponent(url.pathname);