aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGhanem <37152329+AbdulrhmnGhanem@users.noreply.github.com>2022-02-17 18:11:27 +0200
committerGitHub <noreply@github.com>2022-02-18 00:11:27 +0800
commit185646723cf6e88943842c8ef10b1c30e3aae647 (patch)
tree1e401492cc7b8e5dd3aa7b659a922d343a2cc121
parent397d2ac303d7dd34295537a5776bb77903100715 (diff)
downloadgitea-185646723cf6e88943842c8ef10b1c30e3aae647.tar.gz
gitea-185646723cf6e88943842c8ef10b1c30e3aae647.zip
Fix redirect when using lowercase reponame (#18775)
* Previously, `GET {username}/{reponame}/raw///file-path` (the middle two slashes are blank to get the default branch) when the repo name has uppercase letters, e.g., https://try.gitea.io/AbdulrhmnGhanem/CH330_Hardware, using a lowercase version of the name redirected to the correct URL * In other words both * `GET https://try.gitea.io/AbdulrhmnGhanem/CH330_Hardware/raw///images/back.png` * `GET https://try.gitea.io/AbdulrhmnGhanem/ch330_hardware/raw///images/back.png` were redirecting to ` GET https://try.gitea.io/AbdulrhmnGhanem/CH330_Hardware/raw/branch/master/images/back.png` This isn't the case after #17551. Specifically because of this [line](https://github.com/zeripath/gitea/blob/cbd5eecd148dfca5fcb1a3da469e491a84f6b32b/modules/context/repo.go#L860).
-rw-r--r--modules/context/repo.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 76fe1c5676..355c40af8a 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -914,7 +914,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
if refType == RepoRefLegacy {
// redirect from old URL scheme to new URL scheme
- prefix := strings.TrimPrefix(setting.AppSubURL+strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*")), ctx.Repo.RepoLink)
+ prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*"))), strings.ToLower(ctx.Repo.RepoLink))
ctx.Redirect(path.Join(
ctx.Repo.RepoLink,