From 31d870ec5712c72270b451fdbe0e5b9c36158635 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 29 Jan 2021 10:55:32 +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=E6=97=A7=E7=89=88=E6=9C=AC=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=20path=20=E5=92=8C=20url=20=E5=88=86?= =?UTF-8?q?=E5=BC=80=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/HistoricalDataUpgradeService.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java index 2beaf836c8..0e0d55f483 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -28,7 +28,6 @@ import io.metersphere.base.mapper.ApiTestMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.DateUtils; -import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -42,7 +41,6 @@ import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.net.URL; import java.nio.channels.FileChannel; import java.util.*; @@ -116,18 +114,6 @@ public class HistoricalDataUpgradeService { if (request instanceof HttpRequest) { element = new MsHTTPSamplerProxy(); HttpRequest request1 = (HttpRequest) request; - if (StringUtils.isEmpty(request1.getPath()) && StringUtils.isNotEmpty(request1.getUrl())) { - try { - URL urlObject = new URL(request1.getUrl()); - String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); - request1.setPath(envPath); - request1.setUrl(null); - } catch (Exception ex) { - LogUtil.error(ex.getMessage()); - } - } else { - request1.setUrl(null); - } if (request1.getBody() != null) { request1.getBody().setBinary(new ArrayList<>()); if (request1.getBody().isOldKV()) { @@ -161,6 +147,13 @@ public class HistoricalDataUpgradeService { BeanUtils.copyBean(element, request1); ((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP); ((MsHTTPSamplerProxy) element).setArguments(request1.getParameters()); + if (StringUtils.isNotEmpty(request1.getPath()) && request1.isUseEnvironment()) { + ((MsHTTPSamplerProxy) element).setPath(request1.getPath()); + ((MsHTTPSamplerProxy) element).setUrl(null); + } else { + ((MsHTTPSamplerProxy) element).setPath(null); + ((MsHTTPSamplerProxy) element).setUrl(request1.getUrl()); + } List keyValues = new LinkedList<>(); keyValues.add(new KeyValue("", "")); ((MsHTTPSamplerProxy) element).setRest(keyValues);