fix(接口测试): 修复正则的快捷提取当正则表达式不合法时会影响到页面显示的问题

--bug=1037759 --user=宋天阳 https://www.tapd.cn/55049933/s/1490276
This commit is contained in:
Jianguo-Genius 2024-04-08 15:16:46 +08:00 committed by 刘瑞斌
parent 19b0bf4251
commit 7e2dcb7b6c
2 changed files with 23 additions and 17 deletions

View File

@ -18,7 +18,7 @@ export const ExecuteScenarioUrl = '/api/scenario/run'; // 接口场景执行(
export const GetSystemRequestUrl = '/api/scenario/get/system-request'; // 获取导入的系统请求数据
export const FollowScenarioUrl = '/api/scenario/follow'; // 关注/取消关注接口场景
export const ScenarioScheduleConfigUrl = '/api/scenario/schedule-config'; // 场景定时任务
export const ScenarioScheduleConfigDeleteUrl = '/api/scenario/schedule-config-delete/'; // 场景定时任务
export const ScenarioScheduleConfigDeleteUrl = '/api/scenario/schedule-config-delete'; // 场景定时任务
export const GetStepProjectInfoUrl = '/api/scenario/step/project-ifo'; // 获取跨项目信息
export const BatchRecycleScenarioUrl = '/api/scenario/batch-operation/delete-gc'; // 批量删除接口场景
export const BatchMoveScenarioUrl = '/api/scenario/batch-operation/move'; // 批量移动接口场景

View File

@ -247,25 +247,31 @@
break;
case RequestExtractExpressionEnum.REGEX:
default:
// /g
const matchesIterator = props.response?.matchAll(
new RegExp(expressionForm.value.expression.replace(/^\/|\/$|\/g$/g, ''), 'g')
);
if (matchesIterator) {
const matches = Array.from(matchesIterator);
try {
if (expressionForm.value.expressionMatchingRule === 'EXPRESSION') {
//
matchResult.value = matches.map((e) => e[0]) || [];
} else {
matchResult.value = matches.map((e) => e.slice(1)).flat(Infinity) || []; //
// 便
try {
// /g
const matchesIterator = props.response?.matchAll(
new RegExp(expressionForm.value.expression.replace(/^\/|\/$|\/g$/g, ''), 'g')
);
if (matchesIterator) {
const matches = Array.from(matchesIterator);
try {
if (expressionForm.value.expressionMatchingRule === 'EXPRESSION') {
//
matchResult.value = matches.map((e) => e[0]) || [];
} else {
matchResult.value = matches.map((e) => e.slice(1)).flat(Infinity) || []; //
}
} catch (error) {
//
matchResult.value = [];
isMatched.value = true;
}
} catch (error) {
//
} else {
matchResult.value = [];
isMatched.value = true;
}
} else {
} catch (error) {
console.log(`正则匹配异常:${error}`);
matchResult.value = [];
}
break;