From 42dcc259e7b85ca52b9425dbbb488f4633837547 Mon Sep 17 00:00:00 2001 From: minhvh93 Date: Mon, 2 Dec 2019 20:35:15 +0700 Subject: [PATCH] #1399 [BUG]Can't set file server in subdomain with request path is "/" Former-commit-id: 2914cafeab26ae8a716138bec95ade6953ddd04b --- core/router/path.go | 5 +++++ core/router/path_test.go | 2 ++ 2 files changed, 7 insertions(+) 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..bdf2d4ad 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"}, + {"admin.", "admin.", "/"}, + {"admin./" + WildcardFileParam(), "admin.", "/" + WildcardFileParam()}, {"//api/users\\42", "", "/api/users/42"}, {"admin./users//42", "admin.", "/users/42"}, {"*./users/42/", "*.", "/users/42"},