mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
PR #1400 and resolve conflict
Former-commit-id: cb7e939045f72653827a111c6ccdc2af8e456b02
This commit is contained in:
commit
62034128c3
|
@ -492,7 +492,11 @@ func (api *APIBuilder) HandleDir(requestPath, directory string, opts ...DirOptio
|
||||||
continue
|
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)...)
|
routes = append(routes, api.CreateRoutes([]string{http.MethodGet}, requestPath, h)...)
|
||||||
getRoute.StaticSites = append(getRoute.StaticSites, s)
|
getRoute.StaticSites = append(getRoute.StaticSites, s)
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,11 @@ func splitSubdomainAndPath(fullUnparsedPath string) (subdomain string, path stri
|
||||||
return "", "/"
|
return "", "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
splitPath := strings.Split(s, ".")
|
||||||
|
if len(splitPath) == 2 && splitPath[1] == "" {
|
||||||
|
return splitPath[0] + ".", "/"
|
||||||
|
}
|
||||||
|
|
||||||
slashIdx := strings.IndexByte(s, '/')
|
slashIdx := strings.IndexByte(s, '/')
|
||||||
if slashIdx > 0 {
|
if slashIdx > 0 {
|
||||||
// has subdomain
|
// has subdomain
|
||||||
|
|
|
@ -116,6 +116,8 @@ func TestSplitSubdomainAndPath(t *testing.T) {
|
||||||
path string
|
path string
|
||||||
}{
|
}{
|
||||||
{"admin./users/42", "admin.", "/users/42"},
|
{"admin./users/42", "admin.", "/users/42"},
|
||||||
|
{"static.", "static.", "/"},
|
||||||
|
{"static./" + WildcardFileParam(), "static.", "/" + WildcardFileParam()},
|
||||||
{"//api/users\\42", "", "/api/users/42"},
|
{"//api/users\\42", "", "/api/users/42"},
|
||||||
{"admin./users//42", "admin.", "/users/42"},
|
{"admin./users//42", "admin.", "/users/42"},
|
||||||
{"*./users/42/", "*.", "/users/42"},
|
{"*./users/42/", "*.", "/users/42"},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user