From 91ae9480b865f24d018cdde5cfb9bbbeae7f04e6 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 1 Apr 2021 15:57:44 +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=E5=9C=BA=E6=99=AF=E5=8F=98=E9=87=8F=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/sampler/MsHTTPSamplerProxy.java | 15 ++++---- .../api/jmeter/APIBackendListenerClient.java | 2 +- .../scenario/variable/VariableList.vue | 34 +++++++++---------- frontend/src/i18n/en-US.js | 3 ++ frontend/src/i18n/zh-CN.js | 3 ++ frontend/src/i18n/zh-TW.js | 3 ++ 6 files changed, 33 insertions(+), 27 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 f46e4d1162..4e0a353f18 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 @@ -351,16 +351,13 @@ public class MsHTTPSamplerProxy extends MsTestElement { public boolean isURL(String str) { try { - String regex = "^((https|http|ftp|rtsp|mms)?://)" - + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" - + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "([0-9a-z_!~*'()-]+\\.)*" - + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." - + "[a-z]{2,6})" - + "(:[0-9]{1,5})?" - + "((/?)|" - + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; - return str.matches(regex) || (str.matches("^(http|https|ftp)://.*$") && str.matches(".*://\\$\\{.*$")); + new URL(str); + return true; } catch (Exception e) { + // 支持包含变量的url + if (str.matches("^(http|https|ftp)://.*$") && str.matches(".*://\\$\\{.*$")) { + return true; + } return false; } } diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index 3ecf48632c..92e92bc216 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -247,7 +247,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl } } - if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())||StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) { + if (report != null && StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())||StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) { sendTask(report, reportUrl, testResult); } diff --git a/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue b/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue index 8f23c32cb6..121eda1984 100644 --- a/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue +++ b/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue @@ -1,5 +1,5 @@