You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main_test
import (
"strings""testing""github.com/gofiber/fiber/v2/utils""github.com/stretchr/testify/assert"
)
funcTestShouldBeEmptyString(t*testing.T) {
assert.Equal(t, "", utils.Trim(" ", ' ')) // this is wrong, result is " "assert.Equal(t, "", strings.Trim(" ", " ")) // this is right
}
fix:
// Trim is the equivalent of strings.Trim
func Trim(s string, cutset byte) string {
i, j := 0, len(s)-1
for ; i < j; i++ {
if s[i] != cutset {
break
}
}
for ; i < j; j-- {
if s[j] != cutset {
break
}
}
+ if i == j {+ if s[i] == cutset {+ return ""+ }+ }
return s[i : j+1]
}
The text was updated successfully, but these errors were encountered:
Fiber version
v2.26.0
Issue description
utils.Trim(" ", ' ')
got" "
instead of""
Code snippet
fix:
The text was updated successfully, but these errors were encountered: