Skip to content

Commit 74a5db0

Browse files
hazycorawxiaoguang
andauthored
Fix: treat tab "overview" as "repositories" in user profiles without readme (#27124)
Beginning since 2af30f7, Gitea has a 500 error when visiting a user profile with `?tab=overview` in the URL when the user doesn't have a `.profile/README.md`, because the backend code assumes that if the tab is overview a profile repository must exist, and checks that the repository is nil aren't done. In this PR I treat `?tab=overview` the same as if no tab is set in the URL, which corrects this behaviour- Now, when visiting `?tab=overview`, if `.profile/README.md` exists on that user's profile it'll show that as it should, otherwise it'll show the repositories tab. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 2814f2f commit 74a5db0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

routers/web/user/profile.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ func userProfile(ctx *context.Context) {
7777

7878
func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileGitRepo *git.Repository, profileReadme *git.Blob) {
7979
// if there is a profile readme, default to "overview" page, otherwise, default to "repositories" page
80+
// if there is not a profile readme, the overview tab should be treated as the repositories tab
8081
tab := ctx.FormString("tab")
81-
if tab == "" {
82+
if tab == "" || tab == "overview" {
8283
if profileReadme != nil {
8384
tab = "overview"
8485
} else {

0 commit comments

Comments
 (0)