From 7e2dcb7b6cc96f94c4ba7bbdecf14f789d3f7829 Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Mon, 8 Apr 2024 15:16:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=A3=E5=88=99=E7=9A=84=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=BD=93=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E4=B8=8D=E5=90=88=E6=B3=95=E6=97=B6=E4=BC=9A=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E5=88=B0=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1037759 --user=宋天阳 https://www.tapd.cn/55049933/s/1490276 --- frontend/src/api/requrls/api-test/scenario.ts | 2 +- .../components/fastExtraction/index.vue | 38 +++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/frontend/src/api/requrls/api-test/scenario.ts b/frontend/src/api/requrls/api-test/scenario.ts index eda68fecf6..a37f7fbe29 100644 --- a/frontend/src/api/requrls/api-test/scenario.ts +++ b/frontend/src/api/requrls/api-test/scenario.ts @@ -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'; // 批量移动接口场景 diff --git a/frontend/src/views/api-test/components/fastExtraction/index.vue b/frontend/src/views/api-test/components/fastExtraction/index.vue index cb1e6387a8..511d4843b4 100644 --- a/frontend/src/views/api-test/components/fastExtraction/index.vue +++ b/frontend/src/views/api-test/components/fastExtraction/index.vue @@ -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;