MCPcopy
hub / github.com/gofiber/fiber / findNextParamPosition

Function findNextParamPosition

path.go:325–344  ·  view source on GitHub ↗

findNextParamPosition search for the next possible parameter start position

(pattern string)

Source from the content-addressed store, hash-verified

323
324// findNextParamPosition search for the next possible parameter start position
325func findNextParamPosition(pattern string) int {
326 // Find the first parameter position
327 next := -1
328 for i := range pattern {
329 if parameterStartChars[pattern[i]] && (i == 0 || pattern[i-1] != escapeChar) {
330 next = i
331 break
332 }
333 }
334 if next > 0 && pattern[next] != wildcardParam {
335 // checking the found parameterStartChar is a cluster
336 for i := next + 1; i < len(pattern); i++ {
337 if !parameterStartChars[pattern[i]] {
338 return i - 1
339 }
340 }
341 return len(pattern) - 1
342 }
343 return next
344}
345
346// analyseConstantPart find the end of the constant part and create the route segment
347func (*routeParser) analyseConstantPart(pattern string, nextParamPosition int) (int, *routeSegment) {

Callers 1

parseRouteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected