package server import ( "html" "net/http" "path" "strings" ) func (s *Server) create(w http.ResponseWriter, r *http.Request) { content := r.FormValue("base") content = html.UnescapeString(content) content = strings.ReplaceAll(content, "\r", "") urlPath := path.Join(r.URL.Path, content) p := NewPathFromURL(urlPath) if p.IsDir() { w.WriteHeader(http.StatusBadRequest) return } url := *r.URL url.Path = path.Join("/edit/", p.BaseHREF) http.Redirect(w, r, url.String(), http.StatusSeeOther) }