fix(测试跟踪): 禅道同步缺陷后图片无法展示

--bug=1020301 --user=陈建星 【测试跟踪】github #20125, 同步禅道缺陷后,缺陷内容中的图片无法展示 https://www.tapd.cn/55049933/s/1307379
This commit is contained in:
chenjianxing 2022-11-29 15:47:20 +08:00 committed by jianxing
parent aa3d60c468
commit 329c928d10
1 changed files with 9 additions and 3 deletions

View File

@ -38,6 +38,8 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@ -562,10 +564,14 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
}
} else {
name = name.replaceAll("&", "&");
path = zentaoClient.getBaseUrl() + path.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);
}
}
// 专业版格式有差异解析完会出现两个 /pro去掉一个
path.replace("/pro/pro", "/pro");
path = "/resource/md/get/url?url=" + URLEncoder.encode(path, StandardCharsets.UTF_8);
// 图片与描述信息之间需换行否则无法预览图片
result = "\n\n![" + name + "](" + path + ")";