From f7d4cc4e2de0e7bc3e27733306c40b6e2678c7bd Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 27 Oct 2022 19:04:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhar=E6=96=87=E4=BB=B6=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=BC=95=E7=94=A8=E7=8E=AF=E5=A2=83=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1018879 --user=王孝刚 【接口测试】github#18808。接口自动化导入har包后,不勾选引用环境,执行时还提示要选择运行环境 https://www.tapd.cn/55049933/s/1281253 --- .../io/metersphere/api/parse/HarScenarioAbstractParser.java | 1 + .../io/metersphere/service/scenario/ApiScenarioService.java | 1 + .../business/automation/scenario/common/CustomizeReqInfo.vue | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java index f7af7e7177..9eb3f5bc28 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java @@ -32,6 +32,7 @@ public abstract class HarScenarioAbstractParser extends ApiImportAbstractPars } else { request.setPath("/"); } + request.setUrl(harRequest.url); parseParameters(harRequest, request); parseRequestBody(harRequest, request.getBody()); addBodyHeader(request); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index 8a4e6b6fb3..7339cfd3ae 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -761,6 +761,7 @@ public class ApiScenarioService { Boolean enable = request.getEnvironmentEnable(); String scenarioDefinition = request.getDefinition(); JSONObject element = JSONUtil.parseObject(scenarioDefinition); + ElementUtil.dataFormatting(element); try { Map environmentMap = new HashMap<>(); if (BooleanUtils.isFalse(enable)) { diff --git a/api-test/frontend/src/business/automation/scenario/common/CustomizeReqInfo.vue b/api-test/frontend/src/business/automation/scenario/common/CustomizeReqInfo.vue index be1cefbe92..e9b017b57b 100644 --- a/api-test/frontend/src/business/automation/scenario/common/CustomizeReqInfo.vue +++ b/api-test/frontend/src/business/automation/scenario/common/CustomizeReqInfo.vue @@ -120,7 +120,7 @@ export default { }, setDomain() { let urlStr = this.addProtocol(this.request.url); - const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/g; + const reg = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; if (reg.test(urlStr)) { let url = this.getURL(urlStr); if (url && url.pathname) {