fix(测试跟踪): 修复导入用例后查看详情报错缺陷

--bug=1028181 --user=王旭 【测试跟踪】github#25900,【测试跟踪】标签为数字开头,且含有空格的功能用例,导入后,用例详情页面啥内容也没有。 https://www.tapd.cn/55049933/s/1403774
This commit is contained in:
WangXu10 2023-08-15 14:18:59 +08:00 committed by 刘瑞斌
parent ab6f9f65db
commit 1250c36793
1 changed files with 10 additions and 19 deletions

View File

@ -663,26 +663,17 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
*/
public String modifyTagPattern(TestCaseExcelData data) {
String tags = data.getTags();
try {
if (StringUtils.isNotBlank(tags)) {
JSON.parseArray(tags);
return tags;
}
return "[]";
} catch (Exception e) {
if (tags != null) {
//当标签值以中英文的逗号和分号分隔时才能正确解析
Stream<String> stringStream = Arrays.stream(tags.split("[,;\"\\r|\\n|\\r\\n\"]"));
//替换非法字符反斜杠"\""\\"
List<String> tagList = stringStream.map(tag -> tag = "\"" + tag.replaceAll("\\\\", "\\\\\\\\") + "\"")
.collect(Collectors.toList());
String modifiedTags = StringUtils.join(tagList, ",");
modifiedTags = "[" + modifiedTags + "]";
return modifiedTags;
} else {
return "[]";
}
if (StringUtils.isNotBlank(tags)) {
//当标签值以中英文的逗号和分号分隔时才能正确解析
Stream<String> stringStream = Arrays.stream(tags.split("[,;\"\\r|\\n|\\r\\n\"]"));
//替换非法字符反斜杠"\""\\"
List<String> tagList = stringStream.map(tag -> tag = "\"" + tag.replaceAll("\\\\", "\\\\\\\\") + "\"")
.collect(Collectors.toList());
String modifiedTags = StringUtils.join(tagList, ",");
modifiedTags = "[" + modifiedTags + "]";
return modifiedTags;
}
return "[]";
}
/**