Fix UI loading redirections. Should fix #906

This commit is contained in:
Deluan
2021-03-29 20:13:04 -04:00
parent 404253a881
commit 3b0defefec
3 changed files with 17 additions and 1 deletions
+6
View File
@@ -6,6 +6,7 @@ import (
"io/fs"
"io/ioutil"
"net/http"
"path"
"strings"
"github.com/microcosm-cc/bluemonday"
@@ -19,6 +20,11 @@ import (
func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
policy := bluemonday.UGCPolicy()
return func(w http.ResponseWriter, r *http.Request) {
base := path.Join(conf.Server.BaseURL, consts.URLPathUI)
if r.URL.Path == base {
http.Redirect(w, r, base+"/", 302)
}
c, err := ds.User(r.Context()).CountAll()
firstTime := c == 0 && err == nil