fix(stringx): return empty string from FirstN when n is negative (#5620)

This commit is contained in:
SapirBaruch
2026-06-21 05:30:48 +03:00
committed by GitHub
parent d9cb246301
commit 18305200d2
2 changed files with 16 additions and 0 deletions

View File

@@ -34,6 +34,10 @@ func Filter(s string, remove func(r rune) bool) string {
// FirstN returns first n runes from s.
func FirstN(s string, n int, ellipsis ...string) string {
if n < 0 {
return ""
}
var i int
for j := range s {