Skip to content

Commit

Permalink
PR #1400 and resolve conflict
Browse files Browse the repository at this point in the history
Former-commit-id: cb7e939045f72653827a111c6ccdc2af8e456b02
  • Loading branch information
kataras committed Dec 13, 2019
2 parents 04477c3 + 137fa92 commit 6203412
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/router/api_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 5 additions & 0 deletions core/router/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions core/router/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 6203412

Please sign in to comment.