Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some panic information when multiple similar wildcards conflict #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ walk:
if n.nType != catchAll {
pathSeg = strings.SplitN(pathSeg, "/", 2)[0]
}
prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
prefix := fullPath[:strings.LastIndex(fullPath, path)] + n.path
panic("'" + pathSeg +
"' in new path '" + fullPath +
"' conflicts with existing wildcard '" + n.path +
Expand Down
2 changes: 2 additions & 0 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ func TestTreeWildcardConflictEx(t *testing.T) {
{"/who/are/foo/bar", "/foo/bar", `/who/are/\*you`, `/\*you`},
{"/conxxx", "xxx", `/con:tact`, `:tact`},
{"/conooo/xxx", "ooo", `/con:tact`, `:tact`},
{"/whose/:users/:user", ":user", `/whose/:users/:name`, `:name`},
}

for _, conflict := range conflicts {
Expand All @@ -681,6 +682,7 @@ func TestTreeWildcardConflictEx(t *testing.T) {
"/con:tact",
"/who/are/*you",
"/who/foo/hello",
"/whose/:users/:name",
}

for _, route := range routes {
Expand Down