Skip to content

Commit ae5e19a

Browse files
AbdulrhmnGhanemStelios Malathouras
authored and
Stelios Malathouras
committed
Fix redirect when using lowercase reponame (go-gitea#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 go-gitea#17551. Specifically because of this [line](https://github.com/zeripath/gitea/blob/cbd5eecd148dfca5fcb1a3da469e491a84f6b32b/modules/context/repo.go#L860).
1 parent 8ff1bb2 commit ae5e19a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/context/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
914914

915915
if refType == RepoRefLegacy {
916916
// redirect from old URL scheme to new URL scheme
917-
prefix := strings.TrimPrefix(setting.AppSubURL+strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*")), ctx.Repo.RepoLink)
917+
prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*"))), strings.ToLower(ctx.Repo.RepoLink))
918918

919919
ctx.Redirect(path.Join(
920920
ctx.Repo.RepoLink,

0 commit comments

Comments
 (0)