Skip to content

Commit 85905ae

Browse files
committed
fixes a regression for wildcard param checking
1 parent 403a33c commit 85905ae

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎tree.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,6 @@ func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) {
651651
}
652652

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

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

0 commit comments

Comments
 (0)