PR #1400 and resolve conflict

Former-commit-id: cb7e939045f72653827a111c6ccdc2af8e456b02
This commit is contained in:
Gerasimos (Makis) Maropoulos 2019-12-13 23:08:26 +02:00
commit 62034128c3
3 changed files with 12 additions and 1 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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"},