fix tsr with mixed static and wildcard paths (#2924)

This commit is contained in:
Ibraheem Ahmed
2021-10-31 20:21:37 -04:00
committed by GitHub
parent d4e72a17f7
commit cbdd47a7e1
2 changed files with 48 additions and 25 deletions
+25 -2
View File
@@ -587,7 +587,14 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/doc/go1.html",
"/no/a",
"/no/b",
"/api/hello/:name",
"/api/:page/:name",
"/api/hello/:name/bar/",
"/api/bar/:name",
"/api/baz/foo",
"/api/baz/foo/bar",
"/blog/:p",
"/posts/:b/:c",
"/posts/b/:c/d/",
}
for _, route := range routes {
recv := catchPanic(func() {
@@ -613,7 +620,19 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/admin/config/",
"/admin/config/permissions/",
"/doc/",
"/admin/static/",
"/admin/cfg/",
"/admin/cfg/users/",
"/api/hello/x/bar",
"/api/baz/foo/",
"/api/baz/bax/",
"/api/bar/huh/",
"/api/baz/foo/bar/",
"/api/world/abc/",
"/blog/pp/",
"/posts/b/c/d",
}
for _, route := range tsrRoutes {
value := tree.getValue(route, nil, getSkippedNodes(), false)
if value.handlers != nil {
@@ -629,7 +648,11 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/no/",
"/_",
"/_/",
"/api/world/abc",
"/api",
"/api/",
"/api/hello/x/foo",
"/api/baz/foo/bad",
"/foo/p/p",
}
for _, route := range noTsrRoutes {
value := tree.getValue(route, nil, getSkippedNodes(), false)