From 08ba895c2b871c309e7787110fbde21214a3d684 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Wed, 14 Apr 2021 23:59:42 +0800 Subject: [PATCH] fix wrong file link in code search page (#15466) 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> --- routers/repo/search.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routers/repo/search.go b/routers/repo/search.go index af4fe9ef12..d9604bade0 100644 --- a/routers/repo/search.go +++ b/routers/repo/search.go @@ -6,7 +6,6 @@ package repo import ( "net/http" - "path" "strings" "code.gitea.io/gitea/modules/base" @@ -41,7 +40,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