Skip to content
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