#1399 [BUG]Can't set file server in subdomain with request path is "/"

Former-commit-id: 2914cafeab26ae8a716138bec95ade6953ddd04b
This commit is contained in:
minhvh93 2019-12-02 20:35:15 +07:00
parent 4e9a6be9aa
commit 42dcc259e7
2 changed files with 7 additions and 0 deletions

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"},
{"admin.", "admin.", "/"},
{"admin./" + WildcardFileParam(), "admin.", "/" + WildcardFileParam()},
{"//api/users\\42", "", "/api/users/42"},
{"admin./users//42", "admin.", "/users/42"},
{"*./users/42/", "*.", "/users/42"},