Skip to content

Commit

Permalink
fix: type/stringsutil: fix ToUpperFirst() for zero length input
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Nov 23, 2024
1 parent e051164 commit f1ba7b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion type/stringsutil/stringsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func ToUpperFirst(s1 string, lowerRest bool) string {
s1 = strings.ToLower(s1)
}
a1 := []rune(s1)
a1[0] = unicode.ToUpper(a1[0])
if len(a1) > 0 {
a1[0] = unicode.ToUpper(a1[0])
}
return string(a1)
}

Expand Down

0 comments on commit f1ba7b3

Please sign in to comment.