From 102b89594338f8f3c2a565bb74536e8f1d42c267 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 19 Jul 2021 18:32:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E7=89=B9=E6=AE=8AURL=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E9=97=AE=E9=A2=98=EF=BC=8C=E5=A6=82url=E7=BB=93?= =?UTF-8?q?=E5=B0=BE=E6=97=B6=EF=BC=9F=E6=89=A7=E8=A1=8C=E6=97=B6=20?= =?UTF-8?q?=EF=BC=9F=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/sampler/MsHTTPSamplerProxy.java | 8 +++--- .../api/service/ApiAutomationService.java | 4 ++- .../scenario/common/CustomizeReqInfo.vue | 25 ++++++++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index a765701cb4..ce755e41e0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -312,7 +312,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setPort(urlObject.getPort()); } sampler.setProtocol(urlObject.getProtocol()); - sampler.setPath(URLDecoder.decode(URLEncoder.encode(urlObject.getPath(), "UTF-8"), "UTF-8")); + sampler.setPath(URLDecoder.decode(URLEncoder.encode(urlObject.getFile(), "UTF-8"), "UTF-8")); } catch (Exception e) { LogUtil.error(e.getMessage(), e); } @@ -324,7 +324,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { String envPath = ""; if (!isCustomizeReqCompleteUrl(this.path)) { URL urlObject = new URL(url); - envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); + envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile(); if (StringUtils.isNotBlank(this.getPath())) { envPath += this.getPath(); } @@ -338,7 +338,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setPort(httpConfig.getPort()); } else { URL urlObject = new URL(this.path); - envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); + envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile(); sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8")); sampler.setProtocol(urlObject.getProtocol()); } @@ -385,7 +385,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setPort(urlObject.getPort()); } sampler.setProtocol(urlObject.getProtocol()); - String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); + String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile(); sampler.setPath(envPath); if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) { envPath = getRestParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8")); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index fdcb0b2072..42baaf15a2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1040,7 +1040,9 @@ public class ApiAutomationService { public void run() { List reportIds = new LinkedList<>(); for (APIScenarioReportResult key : map.keySet()) { - key.setExecuteType(ExecuteType.Marge.name()); + if (StringUtils.isNotEmpty(serialReportId)) { + key.setExecuteType(ExecuteType.Marge.name()); + } apiScenarioReportMapper.insert(key); reportIds.add(key.getId()); try { diff --git a/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue b/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue index 83bdefb580..4cd3c9974c 100644 --- a/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue +++ b/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue @@ -13,7 +13,7 @@ - {{$t('api_test.request.refer_to_environment')}} + {{ $t('api_test.request.refer_to_environment') }}
@@ -45,6 +45,7 @@ export default { data() { return { reqOptions: REQ_METHOD, + isUrl: false, } }, mounted() { @@ -69,20 +70,25 @@ export default { }, methods: { pathChange() { + this.isUrl = false; if (!this.request.path || this.request.path.indexOf('?') === -1) return; let url = this.getURL(this.addProtocol(this.request.path)); - if (url) { + if (url && this.isUrl) { this.request.path = decodeURIComponent(this.request.path.substr(0, this.request.path.indexOf("?"))); } }, urlChange() { + this.isUrl = false; if (this.isCustomizeReq) { this.request.path = this.request.url; } if (!this.request.url || this.request.url.indexOf('?') === -1) return; let url = this.getURL(this.addProtocol(this.request.url)); if (url) { - this.request.url = decodeURIComponent(this.request.url.substr(0, this.request.url.indexOf("?"))); + let paramUrl = this.request.url.substr(this.request.url.indexOf("?") + 1); + if (paramUrl && this.isUrl) { + this.request.url = decodeURIComponent(this.request.url.substr(0, this.request.url.indexOf("?"))); + } } }, addProtocol(url) { @@ -98,6 +104,7 @@ export default { let url = new URL(urlStr); url.searchParams.forEach((value, key) => { if (key && value) { + this.isUrl = true; this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value})); } }); @@ -111,11 +118,11 @@ export default {