Skip to content

Commit 6fd8a1f

Browse files
committed
code: Support attachment file path in README.md
1 parent ad2cf1a commit 6fd8a1f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/utils/Markdown.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private static String replaceImageLinkPath(Project project, String text){
243243
if (StringUtils.isNotEmpty(root)) {
244244
root = "/" + root;
245245
}
246-
final String imageLink = "!\\[(?<text>[^\\]]*)\\]\\(\\/?(?!https\\:|http\\:|ftp\\:|file\\:)(?<link>[^\\)]*)\\)";
246+
final String imageLink = "!\\[(?<text>[^]]*)]\\(/?(?!https:|http:|ftp:|file:)[.][/](?<link>.*)\\)";
247247
return text.replaceAll(imageLink, "![$1](/" + root + project.owner + "/" + project.name + "/files/" + project.defaultBranch().replaceAll("refs/heads/", "") + "/$2)");
248248
}
249249

@@ -252,8 +252,8 @@ private static String replaceContentsLinkToCodeBrowerPath(Project project, Strin
252252
if (StringUtils.isNotEmpty(root)) {
253253
root = "/" + root;
254254
}
255-
final String imageLink = "!\\[(?<text>[^\\]]*)\\]\\(\\/?(?!https\\:|http\\:|ftp\\:|file\\:)(?<link>[^\\)]*)\\)";
256-
final String normalLocalLink = "(?<space>[^!])\\[(?<text>[^\\]]*)\\]\\(\\/?(?!https\\:|http\\:|ftp\\:|file\\:)(?<link>[^\\)]*)\\)";
255+
final String imageLink = "!\\[(?<text>[^]]*)]\\(/?(?!https:|http:|ftp:|file:)[.][/](?<link>.*)\\)";
256+
final String normalLocalLink = "(?<space>[^!])\\[(?<text>[^]]*)]\\(/?(?!https:|http:|ftp:|file:)[.][/](?<link>.*)\\)";
257257
String imageFilteredText = text.replaceAll(imageLink, "![$1](/" + root + project.owner + "/" + project.name + "/files/" + project.defaultBranch().replaceAll("refs/heads/", "") + "/$2)");
258258
return imageFilteredText.replaceAll(normalLocalLink, "$1[$2](/" + root + project.owner + "/" + project.name + "/code/" + project.defaultBranch().replaceAll("refs/heads/", "") + "/$3)");
259259

0 commit comments

Comments
 (0)