-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix duplicate sub-path for avatars #31365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a1daf7d
fix
wxiaoguang ab033e1
Update custom/conf/app.example.ini
wxiaoguang 55f92ab
Update modules/setting/server.go
wxiaoguang f0d42a4
fix typo
wxiaoguang 3f6d30c
Update routers/common/middleware.go
wxiaoguang 7866c43
Merge branch 'main' into fix-sub-path
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package repo | ||
|
||
import ( | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/test" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRepoAvatarLink(t *testing.T) { | ||
defer test.MockVariableValue(&setting.AppURL, "https://localhost/")() | ||
defer test.MockVariableValue(&setting.AppSubURL, "")() | ||
|
||
repo := &Repository{ID: 1, Avatar: "avatar.png"} | ||
link := repo.AvatarLink(db.DefaultContext) | ||
assert.Equal(t, "https://localhost/repo-avatars/avatar.png", link) | ||
|
||
setting.AppURL = "https://localhost/sub-path/" | ||
setting.AppSubURL = "/sub-path" | ||
link = repo.AvatarLink(db.DefaultContext) | ||
assert.Equal(t, "https://localhost/sub-path/repo-avatars/avatar.png", link) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package user | ||
|
||
import ( | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/test" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUserAvatarLink(t *testing.T) { | ||
defer test.MockVariableValue(&setting.AppURL, "https://localhost/")() | ||
defer test.MockVariableValue(&setting.AppSubURL, "")() | ||
|
||
u := &User{ID: 1, Avatar: "avatar.png"} | ||
link := u.AvatarLink(db.DefaultContext) | ||
assert.Equal(t, "https://localhost/avatars/avatar.png", link) | ||
|
||
setting.AppURL = "https://localhost/sub-path/" | ||
setting.AppSubURL = "/sub-path" | ||
link = u.AvatarLink(db.DefaultContext) | ||
assert.Equal(t, "https://localhost/sub-path/avatars/avatar.png", link) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package setting | ||
|
||
// Global settings | ||
var ( | ||
// RunUser is the OS user that Gitea is running as. ini:"RUN_USER" | ||
RunUser string | ||
// RunMode is the running mode of Gitea, it only accepts two values: "dev" and "prod". | ||
// Non-dev values will be replaced by "prod". ini: "RUN_MODE" | ||
RunMode string | ||
// IsProd is true if RunMode is not "dev" | ||
IsProd bool | ||
|
||
// AppName is the Application name, used in the page title. ini: "APP_NAME" | ||
AppName string | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.