mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Clarify the suffices and prefixes of setting.AppSubURL and setting.AppURL (#12999)
Also removes some unnecessary uses of fmt.Sprintf and adds documentation strings Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
@@ -26,7 +26,7 @@ func TestAction_GetRepoLink(t *testing.T) {
|
||||
repo := AssertExistsAndLoadBean(t, &Repository{}).(*Repository)
|
||||
owner := AssertExistsAndLoadBean(t, &User{ID: repo.OwnerID}).(*User)
|
||||
action := &Action{RepoID: repo.ID}
|
||||
setting.AppSubURL = "/suburl/"
|
||||
setting.AppSubURL = "/suburl"
|
||||
expected := path.Join(setting.AppSubURL, owner.Name, repo.Name)
|
||||
assert.Equal(t, expected, action.GetRepoLink())
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
@@ -413,7 +413,7 @@ func (n *Notification) HTMLURL() string {
|
||||
|
||||
// APIURL formats a URL-string to the notification
|
||||
func (n *Notification) APIURL() string {
|
||||
return setting.AppURL + path.Join("api/v1/notifications/threads", fmt.Sprintf("%d", n.ID))
|
||||
return setting.AppURL + "api/v1/notifications/threads/" + strconv.FormatInt(n.ID, 10)
|
||||
}
|
||||
|
||||
// NotificationList contains a list of notifications
|
||||
|
@@ -318,7 +318,7 @@ func (repo *Repository) CommitLink(commitID string) (result string) {
|
||||
|
||||
// APIURL returns the repository API URL
|
||||
func (repo *Repository) APIURL() string {
|
||||
return setting.AppURL + path.Join("api/v1/repos", repo.FullName())
|
||||
return setting.AppURL + "api/v1/repos/" + repo.FullName()
|
||||
}
|
||||
|
||||
// GetCommitsCountCacheKey returns cache key used for commits count caching.
|
||||
|
@@ -63,7 +63,7 @@ func (u *User) generateRandomAvatar(e Engine) error {
|
||||
// the local explore page. Function returns immediately.
|
||||
// When applicable, the link is for an avatar of the indicated size (in pixels).
|
||||
func (u *User) SizedRelAvatarLink(size int) string {
|
||||
return strings.TrimSuffix(setting.AppSubURL, "/") + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size)
|
||||
return setting.AppSubURL + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size)
|
||||
}
|
||||
|
||||
// RealSizedAvatarLink returns a link to the user's avatar. When
|
||||
|
Reference in New Issue
Block a user