Browse Source

Refactor use TrimSuffix instead of TrimRight (#12993)

* Refactor use TrimSuffix instead of TrimRight

* TrimRight right

* has #12990
tags/v1.13.0-rc1
6543 GitHub 5 years ago
parent
commit
50b8a9b0a0
3 changed files with 3 additions and 3 deletions
  1. +1
    -1
      cmd/web.go
  2. +1
    -1
      models/user.go
  3. +1
    -1
      modules/setting/setting.go

+ 1
- 1
cmd/web.go View File

@@ -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)
}



+ 1
- 1
models/user.go View File

@@ -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


+ 1
- 1
modules/setting/setting.go View File

@@ -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 {


Loading…
Cancel
Save