diff --git a/ctx.go b/ctx.go index 07ffb1db..b2d13c0a 100644 --- a/ctx.go +++ b/ctx.go @@ -1349,7 +1349,7 @@ func (c *DefaultCtx) getLocationFromRoute(route Route, params Map) (string, erro for key, val := range params { isSame := key == segment.ParamName || (!c.app.config.CaseSensitive && utils.EqualFold(key, segment.ParamName)) - isGreedy := segment.IsGreedy && len(key) == 1 && isInCharset(key[0], greedyParameters) + isGreedy := segment.IsGreedy && len(key) == 1 && bytes.IndexByte(greedyParameters, key[0]) != -1 if isSame || isGreedy { _, err := buf.WriteString(utils.ToString(val)) if err != nil { diff --git a/path.go b/path.go index fdd61e39..76236e40 100644 --- a/path.go +++ b/path.go @@ -7,6 +7,7 @@ package fiber import ( + "bytes" "regexp" "strconv" "strings" @@ -308,7 +309,7 @@ func (routeParser *routeParser) analyseParameterPart(pattern string, customConst parameterEndPosition = 0 case parameterEndPosition == -1: parameterEndPosition = len(pattern) - 1 - case !isInCharset(pattern[parameterEndPosition+1], parameterDelimiterChars): + case bytes.IndexByte(parameterDelimiterChars, pattern[parameterEndPosition+1]) == -1: parameterEndPosition++ } @@ -397,16 +398,6 @@ func (routeParser *routeParser) analyseParameterPart(pattern string, customConst return n, segment } -// isInCharset check is the given character in the charset list -func isInCharset(searchChar byte, charset []byte) bool { - for _, char := range charset { - if char == searchChar { - return true - } - } - return false -} - // findNextCharsetPosition search the next char position from the charset func findNextCharsetPosition(search string, charset []byte) int { nextPosition := -1