refactor(测试跟踪): 同步禅道图片后保存缺陷失败

--bug=1013707 --user=陈建星 【测试跟踪】github #14185禅道创建的bug 包含图片 同步到ms ,在ms编辑缺陷内容,点击保存保存失败 https://www.tapd.cn/55049933/s/1170263
This commit is contained in:
chenjianxing 2022-05-31 19:15:32 +08:00 committed by jianxing
parent 8f12897e9d
commit 4f1053728e
1 changed files with 24 additions and 13 deletions

View File

@ -35,6 +35,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
@ -398,8 +399,17 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
while (matcher.find()) {
// get file name
String originSubUrl = matcher.group(1);
if (originSubUrl.contains("/url?url=")) {
String path = URLDecoder.decode(originSubUrl, StandardCharsets.UTF_8);
String fileName;
if (path.indexOf("fileID") > 0) {
fileName = path.substring(path.indexOf("fileID") + 7);
} else {
fileName = path.substring(path.indexOf("file-read-") + 10);
}
zentaoSteps = zentaoSteps.replaceAll(Pattern.quote(originSubUrl), fileName);
} else {
String fileName = originSubUrl.substring(10);
fileName = resourceService.decodeFileName(fileName);
// get file
ResponseEntity<FileSystemResource> mdImage = resourceService.getMdImage(fileName);
// upload zentao
@ -413,6 +423,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
// replace id
zentaoSteps = zentaoSteps.replaceAll(Pattern.quote(originSubUrl), id + suffix);
}
}
// image link
String netImgRegex = "!\\[(.*?)]\\((http.*?)\\)";
return zentaoSteps.replaceAll(netImgRegex, "<img src=\"$2\" alt=\"$1\"/>");