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) url := *r.URL path, err := s.Notes.Create(urlPath) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } url.Path = path http.Redirect(w, r, url.String(), http.StatusSeeOther) }