diff --git a/core/router/api_builder.go b/core/router/api_builder.go index 04a44477..06cc7353 100644 --- a/core/router/api_builder.go +++ b/core/router/api_builder.go @@ -492,7 +492,11 @@ func (api *APIBuilder) HandleDir(requestPath, directory string, opts ...DirOptio continue } - requestPath := s.RequestPath[strings.Index(s.RequestPath, api.relativePath)+len(api.relativePath):] + slashIdx := strings.IndexByte(s.RequestPath, '/') + if slashIdx == -1 { + slashIdx = 0 + } + requestPath = s.RequestPath[slashIdx:] routes = append(routes, api.CreateRoutes([]string{http.MethodGet}, requestPath, h)...) getRoute.StaticSites = append(getRoute.StaticSites, s) } diff --git a/core/router/path.go b/core/router/path.go index 6c32c863..6d9b687a 100644 --- a/core/router/path.go +++ b/core/router/path.go @@ -231,6 +231,11 @@ func splitSubdomainAndPath(fullUnparsedPath string) (subdomain string, path stri return "", "/" } + splitPath := strings.Split(s, ".") + if len(splitPath) == 2 && splitPath[1] == "" { + return splitPath[0] + ".", "/" + } + slashIdx := strings.IndexByte(s, '/') if slashIdx > 0 { // has subdomain diff --git a/core/router/path_test.go b/core/router/path_test.go index 2b2c7538..5e5c6abc 100644 --- a/core/router/path_test.go +++ b/core/router/path_test.go @@ -116,6 +116,8 @@ func TestSplitSubdomainAndPath(t *testing.T) { path string }{ {"admin./users/42", "admin.", "/users/42"}, + {"static.", "static.", "/"}, + {"static./" + WildcardFileParam(), "static.", "/" + WildcardFileParam()}, {"//api/users\\42", "", "/api/users/42"}, {"admin./users//42", "admin.", "/users/42"}, {"*./users/42/", "*.", "/users/42"},