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 = ""; String result = "";
if (StringUtils.isNotEmpty(path)) { if (StringUtils.isNotEmpty(path)) {
if (path.startsWith("{") && path.endsWith("}")) { if (!path.startsWith("http")) {
String srcContent = path.substring(1, path.length() - 1); if (path.startsWith("{") && path.endsWith("}")) {
if (StringUtils.isEmpty(name)) { String srcContent = path.substring(1, path.length() - 1);
name = srcContent; if (StringUtils.isEmpty(name)) {
} name = srcContent;
}
if (Arrays.stream(imgArray).anyMatch(imgType -> StringUtils.equals(imgType, srcContent.substring(srcContent.indexOf('.') + 1)))) { if (Arrays.stream(imgArray).anyMatch(imgType -> StringUtils.equals(imgType, srcContent.substring(srcContent.indexOf('.') + 1)))) {
if (zentaoClient instanceof ZentaoGetClient) { if (zentaoClient instanceof ZentaoGetClient) {
path = zentaoClient.getBaseUrl() + "/index.php?m=file&f=read&fileID=" + srcContent; path = zentaoClient.getBaseUrl() + "/index.php?m=file&f=read&fileID=" + srcContent;
} else {
// 禅道开源版
path = zentaoClient.getBaseUrl() + "/file-read-" + srcContent;
}
} else { } else {
// 禅道开源版 return result;
path = zentaoClient.getBaseUrl() + "/file-read-" + srcContent;
} }
} else { } else {
return result; name = name.replaceAll("&", "&");
} try {
} else { URI uri = new URI(zentaoClient.getBaseUrl());
name = name.replaceAll("&", "&"); path = uri.getScheme() + "://" + uri.getHost() + path.replaceAll("&", "&");
try { } catch (URISyntaxException e) {
URI uri = new URI(zentaoClient.getBaseUrl()); path = zentaoClient.getBaseUrl() + path.replaceAll("&", "&");
path = uri.getScheme() + "://" + uri.getHost() + path.replaceAll("&", "&"); LogUtil.error(e);
} 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 + ")"; result = "\n\n![" + name + "](" + path + ")";
} }