diff options
author | Ghanem <37152329+AbdulrhmnGhanem@users.noreply.github.com> | 2022-02-17 18:11:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-18 00:11:27 +0800 |
commit | 185646723cf6e88943842c8ef10b1c30e3aae647 (patch) | |
tree | 1e401492cc7b8e5dd3aa7b659a922d343a2cc121 | |
parent | 397d2ac303d7dd34295537a5776bb77903100715 (diff) | |
download | gitea-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.go | 2 |
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, |