Skip to content

Commit

Permalink
fixes a regression for wildcard param checking
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Feb 24, 2019
1 parent 403a33c commit 85905ae
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,6 @@ func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) {
}

// Sanity check
if ws >= 0 && ws != len(pattern)-1 {
panic("chi: wildcard '*' must be the last value in a route. trim trailing text or use a '{param}' instead")
}
if ps >= 0 && ws >= 0 && ws < ps {
panic("chi: wildcard '*' must be the last pattern in a route, otherwise use a '{param}'")
}
Expand Down Expand Up @@ -709,7 +706,9 @@ func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) {
}

// Wildcard pattern as finale
// TODO: should we panic if there is stuff after the * ???
if ws < len(pattern)-1 {
panic("chi: wildcard '*' must be the last value in a route. trim trailing text or use a '{param}' instead")
}
return ntCatchAll, "*", "", 0, ws, len(pattern)
}

Expand Down

0 comments on commit 85905ae

Please sign in to comment.