diff options
author | 6543 <6543@obermui.de> | 2020-10-01 07:54:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 06:54:34 +0100 |
commit | 818d921bbb665ab966149523b02e8590efc9d9b4 (patch) | |
tree | 09d064bf150b25925249da9d6fa8ae6fd066c054 | |
parent | 551473b29486489a0cd0d88a86de54db1c44c122 (diff) | |
download | gitea-818d921bbb665ab966149523b02e8590efc9d9b4.tar.gz gitea-818d921bbb665ab966149523b02e8590efc9d9b4.zip |
Refactor use TrimSuffix instead of TrimRight (#12993)
* Refactor use TrimSuffix instead of TrimRight
* TrimRight right
* has #12990
-rw-r--r-- | cmd/web.go | 2 | ||||
-rw-r--r-- | models/user.go | 2 | ||||
-rw-r--r-- | modules/setting/setting.go | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/cmd/web.go b/cmd/web.go index f0e1b16e7f..92d4b11b69 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -93,7 +93,7 @@ func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) { // Remove the trailing slash at the end of setting.AppURL, the request // URI always contains a leading slash, which would result in a double // slash - target := strings.TrimRight(setting.AppURL, "/") + r.URL.RequestURI() + target := strings.TrimSuffix(setting.AppURL, "/") + r.URL.RequestURI() http.Redirect(w, r, target, http.StatusFound) } diff --git a/models/user.go b/models/user.go index 650d5a803a..63ce6ffdfc 100644 --- a/models/user.go +++ b/models/user.go @@ -397,7 +397,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.TrimRight(setting.AppSubURL, "/") + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size) + return strings.TrimSuffix(setting.AppSubURL, "/") + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size) } // RealSizedAvatarLink returns a link to the user's avatar. When diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 26f226fe53..867641e61b 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -934,7 +934,7 @@ func NewContext() { sec = Cfg.Section("U2F") U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/"))) - U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/")) + U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/")) UI.ReactionsMap = make(map[string]bool) for _, reaction := range UI.Reactions { |