diff --git a/src/main/scala/gitbucket/core/view/Markdown.scala b/src/main/scala/gitbucket/core/view/Markdown.scala index 772f1abbf..351caeb1a 100644 --- a/src/main/scala/gitbucket/core/view/Markdown.scala +++ b/src/main/scala/gitbucket/core/view/Markdown.scala @@ -9,6 +9,7 @@ import gitbucket.core.service.{RepositoryService, RequestCache} import gitbucket.core.util.StringUtil import io.github.gitbucket.markedj._ import io.github.gitbucket.markedj.Utils._ +import gitbucket.core.service.WikiService object Markdown { @@ -75,7 +76,8 @@ object Markdown { )(implicit val context: Context) extends Renderer(options) with LinkConverter - with RequestCache { + with RequestCache + with WikiService { override def heading(text: String, level: Int, raw: String): String = { val id = generateAnchorName(text) @@ -193,8 +195,11 @@ object Markdown { } } else { // URL is being modified to link to the image file on the repository, but users may want to link to the page if the page name is a link. - // As a interim solution, if the link contains a ., it will use the current conversion, otherwise it will perform the conversion the user wants. - if (url.lastIndexOf(".") > 0) { + // If the wiki page cannot be retrieved from the url, the blob address is returned; otherwise, the page address is returned. + val pathElems = context.currentPath.split("/") + val owner = pathElems(1) + val repos = pathElems(2) + if (getWikiPage(owner, repos, url, branch) == None) { repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/_blob/" + url } else { repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/" + url