fix(接口定义): 修复har文件导入选择引用环境无效的缺陷

--bug=1018879 --user=王孝刚
【接口测试】github#18808。接口自动化导入har包后,不勾选引用环境,执行时还提示要选择运行环境
https://www.tapd.cn/55049933/s/1281253
This commit is contained in:
wxg0103 2022-10-27 19:04:50 +08:00 committed by fit2-zhao
parent ccc9141b3d
commit f7d4cc4e2d
3 changed files with 3 additions and 1 deletions

View File

@ -32,6 +32,7 @@ public abstract class HarScenarioAbstractParser<T> extends ApiImportAbstractPars
} else { } else {
request.setPath("/"); request.setPath("/");
} }
request.setUrl(harRequest.url);
parseParameters(harRequest, request); parseParameters(harRequest, request);
parseRequestBody(harRequest, request.getBody()); parseRequestBody(harRequest, request.getBody());
addBodyHeader(request); addBodyHeader(request);

View File

@ -761,6 +761,7 @@ public class ApiScenarioService {
Boolean enable = request.getEnvironmentEnable(); Boolean enable = request.getEnvironmentEnable();
String scenarioDefinition = request.getDefinition(); String scenarioDefinition = request.getDefinition();
JSONObject element = JSONUtil.parseObject(scenarioDefinition); JSONObject element = JSONUtil.parseObject(scenarioDefinition);
ElementUtil.dataFormatting(element);
try { try {
Map<String, String> environmentMap = new HashMap<>(); Map<String, String> environmentMap = new HashMap<>();
if (BooleanUtils.isFalse(enable)) { if (BooleanUtils.isFalse(enable)) {

View File

@ -120,7 +120,7 @@ export default {
}, },
setDomain() { setDomain() {
let urlStr = this.addProtocol(this.request.url); 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)) { if (reg.test(urlStr)) {
let url = this.getURL(urlStr); let url = this.getURL(urlStr);
if (url && url.pathname) { if (url && url.pathname) {