StaticEmbedded, if contains "index.html" then act "/" as "/index.html" as requested here: https://github.com/kataras/iris/issues/633

Former-commit-id: 5504d5e454b663e2bfaa194cba4829d9291c1f84
This commit is contained in:
Gerasimos (Makis) Maropoulos 2017-02-22 17:07:21 +02:00
parent 4de98254fd
commit 63dc2339a0

View File

@ -525,6 +525,14 @@ func (router *Router) StaticEmbedded(requestPath string, vdir string, assetFn fu
h := func(ctx *Context) { h := func(ctx *Context) {
reqPath := ctx.Param(paramName) reqPath := ctx.Param(paramName)
for _, path := range names { for _, path := range names {
// in order to map "/" as "/index.html"
// as requested here: https://github.com/kataras/iris/issues/633#issuecomment-281691851
if path == "/index.html" {
if reqPath[len(reqPath)-1] == slashByte {
reqPath = "/index.html"
}
}
if path != reqPath { if path != reqPath {
continue continue
} }