Skip to content

Commit 6039138

Browse files
Fix redirect when using lowercase reponame (#18775) (#18902)
* 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). Co-authored-by: Ghanem <37152329+AbdulrhmnGhanem@users.noreply.github.com>
1 parent eb43e73 commit 6039138

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
@@ -911,7 +911,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
911911

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

916916
ctx.Redirect(path.Join(
917917
ctx.Repo.RepoLink,

0 commit comments

Comments
 (0)