]> source.dussan.org Git - gitea.git/commitdiff
fix wrong file link in code search page (#15466) (#15486)
authora1012112796 <1012112796@qq.com>
Thu, 15 Apr 2021 09:04:25 +0000 (17:04 +0800)
committerGitHub <noreply@github.com>
Thu, 15 Apr 2021 09:04:25 +0000 (12:04 +0300)
in previous the grenrated link is
``testg/testrepo/src/commit/....``
which is not right.

the right version is ``/testg/testrepo/.......``
(start wiht ``/``)
or ``http://127.0.0.1:3000/xxxxx`` (full link)

to make it hase same result with explore page
I choose the secound style.

fix #15438

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: 6543 <6543@obermui.de>
routers/repo/search.go

index 481b64d184a88e70f318a8a2fb154e36bf4c7b85..e23ebb98806c77cb22fd010bf5331fd66097acf4 100644 (file)
@@ -5,7 +5,6 @@
 package repo
 
 import (
-       "path"
        "strings"
 
        "code.gitea.io/gitea/modules/base"
@@ -40,7 +39,7 @@ func Search(ctx *context.Context) {
        ctx.Data["Keyword"] = keyword
        ctx.Data["Language"] = language
        ctx.Data["queryType"] = queryType
-       ctx.Data["SourcePath"] = path.Join(setting.AppSubURL, ctx.Repo.Repository.Owner.Name, ctx.Repo.Repository.Name)
+       ctx.Data["SourcePath"] = ctx.Repo.Repository.HTMLURL()
        ctx.Data["SearchResults"] = searchResults
        ctx.Data["SearchResultLanguages"] = searchResultLanguages
        ctx.Data["RequireHighlightJS"] = true