Skip to content

Commit bfef962

Browse files
KatzuYoruCopilotReneWerner87gaby
authored
🐛 fix: Handling of next param position (#3418)
* fix: the non updating found * Update path.go Co-authored-by: Copilot <[email protected]> * comment: describing the conditional breaking * fix: incorrect logic in finding the cluster start chars * refactor:comment update Co-authored-by: Copilot <[email protected]> * fix: lint issue --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: RW <[email protected]> Co-authored-by: Juan Calderon-Perez <[email protected]>
1 parent ec4b543 commit bfef962

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

path.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,22 @@ func addParameterMetaInfo(segs []*routeSegment) []*routeSegment {
271271

272272
// findNextParamPosition search for the next possible parameter start position
273273
func findNextParamPosition(pattern string) int {
274+
// Find the first parameter position
274275
nextParamPosition := findNextNonEscapedCharsetPosition(pattern, parameterStartChars)
276+
277+
// If pattern contains a parameter and it's not a wildcard
275278
if nextParamPosition != -1 && len(pattern) > nextParamPosition && pattern[nextParamPosition] != wildcardParam {
276-
// search for parameter characters for the found parameter start,
277-
// if there are more, move the parameter start to the last parameter char
278-
for found := findNextNonEscapedCharsetPosition(pattern[nextParamPosition+1:], parameterStartChars); found == 0; {
279-
nextParamPosition++
280-
if len(pattern) > nextParamPosition {
279+
// checking the found parameterStartChar is a cluster
280+
i := nextParamPosition + 1
281+
for i < len(pattern) {
282+
if findNextNonEscapedCharsetPosition(pattern[i:i+1], parameterStartChars) != 0 {
283+
// It was a single parameter start char or end of cluster
281284
break
282285
}
286+
nextParamPosition++
287+
i++
283288
}
284289
}
285-
286290
return nextParamPosition
287291
}
288292

0 commit comments

Comments
 (0)