Skip to content

Commit

Permalink
context: clean RoutePattern suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Jan 3, 2022
1 parent 98fc81f commit 3e5747d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ func (x *Context) URLParam(key string) string {
// }
func (x *Context) RoutePattern() string {
routePattern := strings.Join(x.RoutePatterns, "")
return replaceWildcards(routePattern)
routePattern = replaceWildcards(routePattern)
routePattern = strings.TrimSuffix(routePattern, "//")
routePattern = strings.TrimSuffix(routePattern, "/")
return routePattern
}

// replaceWildcards takes a route pattern and recursively replaces all
Expand All @@ -130,7 +133,6 @@ func replaceWildcards(p string) string {
if strings.Contains(p, "/*/") {
return replaceWildcards(strings.Replace(p, "/*/", "/", -1))
}

return p
}

Expand Down

0 comments on commit 3e5747d

Please sign in to comment.