diff options
author | wxiaoguang | 2023-02-11 14:34:11 +0800 |
---|---|---|
committer | GitHub | 2023-02-11 14:34:11 +0800 |
commit | e9288c24773157411edec17c9bbcc8c1567e91ee (patch) | |
tree | b34c730a13ab9a56d14b0fcccf1e136ca0233b68 /modules | |
parent | 1cb8d14bf71e0b8637c9eaa10808b4fd05139f45 (diff) |
Fix improper HTMLURL usages in Go code (#22839)
In Go code, HTMLURL should be only used for external systems, like
API/webhook/mail/notification, etc.
If a URL is used by `Redirect` or rendered in a template, it should be a
relative URL (aka `Link()` in Gitea)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/context/repo.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index 38c1d8454..a38376ff4 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -743,9 +743,9 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { if ctx.FormString("go-get") == "1" { ctx.Data["GoGetImport"] = ComposeGoGetImport(owner.Name, repo.Name) - prefix := repo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(ctx.Repo.BranchName) - ctx.Data["GoDocDirectory"] = prefix + "{/dir}" - ctx.Data["GoDocFile"] = prefix + "{/dir}/{file}#L{line}" + fullURLPrefix := repo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(ctx.Repo.BranchName) + ctx.Data["GoDocDirectory"] = fullURLPrefix + "{/dir}" + ctx.Data["GoDocFile"] = fullURLPrefix + "{/dir}/{file}#L{line}" } return cancel } |