mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
committed by
Łukasz Mierzwa
parent
b60e349d7e
commit
df80493dd9
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## v0.133
|
||||
|
||||
### Changed
|
||||
|
||||
- Requests for `/index.html` will now be redirected to `/` - #7069.
|
||||
|
||||
## v0.132
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -45,6 +45,11 @@ func serverStaticFiles(prefix, root string) func(next http.Handler) http.Handler
|
||||
fixedPath := strings.TrimPrefix(r.URL.Path, prefix)
|
||||
filePath := strings.TrimSuffix(root, "/") + "/" + strings.TrimPrefix(fixedPath, "/")
|
||||
|
||||
if filepath.Base(filePath) == "index.html" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
slog.Debug(
|
||||
"Static file request",
|
||||
slog.String("path", r.URL.Path),
|
||||
|
||||
@@ -143,6 +143,9 @@ func setupRouter(router *chi.Mux, historyPoller *historyPoller) {
|
||||
if config.Config.Listen.Prefix != "/" {
|
||||
router.Get(getViewURL(""), redirectIndex)
|
||||
}
|
||||
router.Get(getViewURL("/index.html"), func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, getViewURL("/"), http.StatusMovedPermanently)
|
||||
})
|
||||
router.Get(getViewURL("/"), index)
|
||||
router.Get(getViewURL("/version"), versionHandler)
|
||||
router.Get(getViewURL("/health"), pong)
|
||||
|
||||
@@ -137,6 +137,18 @@ func TestIndex(t *testing.T) {
|
||||
request: "/",
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
prefix: "",
|
||||
request: "/index.html",
|
||||
redirect: "/",
|
||||
status: 301,
|
||||
},
|
||||
{
|
||||
prefix: "/prefix",
|
||||
request: "/prefix/index.html",
|
||||
redirect: "/prefix/",
|
||||
status: 301,
|
||||
},
|
||||
{
|
||||
prefix: "",
|
||||
request: "/alertList.json",
|
||||
|
||||
Reference in New Issue
Block a user