fix(测试跟踪): 禅道缺陷上传图片链接后同步,图片不显示

--bug=1020301 --user=陈建星 【测试跟踪】github #20125, 同步禅道缺陷后,缺陷内容中的图片无法展示 https://www.tapd.cn/55049933/s/1308507
This commit is contained in:
chenjianxing 2022-11-30 15:45:33 +08:00 committed by CaptainB
parent 46bbaec98e
commit 30a868df92
1 changed files with 23 additions and 21 deletions

View File

@ -546,33 +546,35 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
String result = "";
if (StringUtils.isNotEmpty(path)) {
if (path.startsWith("{") && path.endsWith("}")) {
String srcContent = path.substring(1, path.length() - 1);
if (StringUtils.isEmpty(name)) {
name = srcContent;
}
if (!path.startsWith("http")) {
if (path.startsWith("{") && path.endsWith("}")) {
String srcContent = path.substring(1, path.length() - 1);
if (StringUtils.isEmpty(name)) {
name = srcContent;
}
if (Arrays.stream(imgArray).anyMatch(imgType -> StringUtils.equals(imgType, srcContent.substring(srcContent.indexOf('.') + 1)))) {
if (zentaoClient instanceof ZentaoGetClient) {
path = zentaoClient.getBaseUrl() + "/index.php?m=file&f=read&fileID=" + srcContent;
if (Arrays.stream(imgArray).anyMatch(imgType -> StringUtils.equals(imgType, srcContent.substring(srcContent.indexOf('.') + 1)))) {
if (zentaoClient instanceof ZentaoGetClient) {
path = zentaoClient.getBaseUrl() + "/index.php?m=file&f=read&fileID=" + srcContent;
} else {
// 禅道开源版
path = zentaoClient.getBaseUrl() + "/file-read-" + srcContent;
}
} else {
// 禅道开源版
path = zentaoClient.getBaseUrl() + "/file-read-" + srcContent;
return result;
}
} else {
return result;
}
} else {
name = name.replaceAll("&", "&");
try {
URI uri = new URI(zentaoClient.getBaseUrl());
path = uri.getScheme() + "://" + uri.getHost() + path.replaceAll("&", "&");
} catch (URISyntaxException e) {
path = zentaoClient.getBaseUrl() + path.replaceAll("&", "&");
LogUtil.error(e);
name = name.replaceAll("&", "&");
try {
URI uri = new URI(zentaoClient.getBaseUrl());
path = uri.getScheme() + "://" + uri.getHost() + path.replaceAll("&", "&");
} catch (URISyntaxException e) {
path = zentaoClient.getBaseUrl() + path.replaceAll("&", "&");
LogUtil.error(e);
}
}
path = "/resource/md/get/url?url=" + URLEncoder.encode(path, StandardCharsets.UTF_8);
}
path = "/resource/md/get/url?url=" + URLEncoder.encode(path, StandardCharsets.UTF_8);
// 图片与描述信息之间需换行否则无法预览图片
result = "\n\n![" + name + "](" + path + ")";
}