fix(接口测试): 使用mock环境,url拼接错误

--bug=1045933 --user=陈建星 [接口测试】接口场景中使用MOCK环境执行,请求URL 地址错误 https://www.tapd.cn/55049933/s/1578907
This commit is contained in:
AgAngle 2024-09-14 14:51:10 +08:00 committed by Craftsman
parent cd26045961
commit 36242372f1
1 changed files with 8 additions and 1 deletions

View File

@ -187,7 +187,14 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
if (httpConfig != null) {
// 接口调试没有环境不取环境的配置
String protocol = httpConfig.getProtocol().toLowerCase();
url = protocol + "://" + (httpConfig.getHostname() + "/" + url).replace("//", "/");
String hostName = httpConfig.getHostname();
if (hostName.lastIndexOf("/") == hostName.length() - 1) {
hostName = hostName.substring(0, hostName.length() - 1);
}
if (url.indexOf("/") == 0) {
url = url.substring(1);
}
url = protocol + "://" + (hostName + "/" + url);
}
url = getPathWithQueryRest(msHTTPElement, url);
return getPathWithQuery(url, msHTTPElement.getQuery());