Browse Source

refactor: Remove unnecessary type conversions (#772)

for-closed-social
Bo-Yi Wu 7 years ago
committed by Lunny Xiao
parent
commit
25663b5816
4 changed files with 5 additions and 5 deletions
  1. +1
    -1
      models/ssh_key.go
  2. +1
    -1
      modules/lfs/server.go
  3. +1
    -1
      modules/markdown/markdown.go
  4. +2
    -2
      modules/templates/helper.go

+ 1
- 1
models/ssh_key.go View File

@ -219,7 +219,7 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) {
func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
fields := strings.Fields(keyLine)
if len(fields) < 2 {
return "", 0, fmt.Errorf("not enough fields in public key line: %s", string(keyLine))
return "", 0, fmt.Errorf("not enough fields in public key line: %s", keyLine)
}
raw, err := base64.StdEncoding.DecodeString(fields[1])

+ 1
- 1
modules/lfs/server.go View File

@ -132,7 +132,7 @@ func GetContentHandler(ctx *context.Context) {
if match != nil && len(match) > 1 {
statusCode = 206
fromByte, _ = strconv.ParseInt(match[1], 10, 32)
ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, meta.Size-1, int64(meta.Size)-fromByte))
ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, meta.Size-1, meta.Size-fromByte))
}
}

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

@ -301,7 +301,7 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
if com.StrTo(m).MustInt() > 0 {
return m
}
return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(string(m)))
return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(m))
}))
}

+ 2
- 2
modules/templates/helper.go View File

@ -121,8 +121,8 @@ func NewFuncMap() []template.FuncMap {
var path []string
index := strings.LastIndex(str, "/")
if index != -1 && index != len(str) {
path = append(path, string(str[0:index+1]))
path = append(path, string(str[index+1:]))
path = append(path, str[0:index+1])
path = append(path, str[index+1:])
} else {
path = append(path, str)
}

Loading…
Cancel
Save