custom domain fixes
alex wennerberg alex@alexwennerberg.com
Sat, 09 Jan 2021 17:46:51 -0800
M
gemini.go
→
gemini.go
@@ -79,8 +79,14 @@ t.Execute(w, data)
} func gmiPage(w *gmi.ResponseWriter, r *gmi.Request) { - logGemini(r) // TODO move into wrapper - userName := filepath.Clean(strings.Split(r.URL.Host, ".")[0]) // clean probably unnecessary + logGemini(r) // TODO move into wrapper + var userName string + custom := domains[r.Host] + if custom != "" { + userName = custom + } else { + userName := filepath.Clean(strings.Split(r.URL.Host, ".")[0]) // clean probably unnecessary + } fileName := filepath.Clean(r.URL.Path) if fileName == "/" { fileName = "index.gmi"
M
http.go
→
http.go
@@ -301,7 +301,8 @@ newEmail := r.Form.Get("email")
newDomain := r.Form.Get("domain") newUsername = strings.ToLower(newUsername) var err error - if newDomain != me.Domain { + _, exists := dict[newDomain] + if newDomain != me.Domain && !exists { _, err = DB.Exec("update user set domain = ? where username = ?", newDomain, me.Username) // TODO use transaction if err != nil { errors = append(errors, err.Error())