Skip to content

Commit 818d921

Browse files
authored
Refactor use TrimSuffix instead of TrimRight (#12993)
* Refactor use TrimSuffix instead of TrimRight * TrimRight right * has #12990
1 parent 551473b commit 818d921

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cmd/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
9393
// Remove the trailing slash at the end of setting.AppURL, the request
9494
// URI always contains a leading slash, which would result in a double
9595
// slash
96-
target := strings.TrimRight(setting.AppURL, "/") + r.URL.RequestURI()
96+
target := strings.TrimSuffix(setting.AppURL, "/") + r.URL.RequestURI()
9797
http.Redirect(w, r, target, http.StatusFound)
9898
}
9999

models/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func (u *User) generateRandomAvatar(e Engine) error {
397397
// the local explore page. Function returns immediately.
398398
// When applicable, the link is for an avatar of the indicated size (in pixels).
399399
func (u *User) SizedRelAvatarLink(size int) string {
400-
return strings.TrimRight(setting.AppSubURL, "/") + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size)
400+
return strings.TrimSuffix(setting.AppSubURL, "/") + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size)
401401
}
402402

403403
// RealSizedAvatarLink returns a link to the user's avatar. When

modules/setting/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ func NewContext() {
934934

935935
sec = Cfg.Section("U2F")
936936
U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/")))
937-
U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))
937+
U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/"))
938938

939939
UI.ReactionsMap = make(map[string]bool)
940940
for _, reaction := range UI.Reactions {

0 commit comments

Comments
 (0)