Remove punctuation from blog IDs

This commit is contained in:
Caleb Gardner
2025-01-26 06:52:45 -06:00
parent cd871c7217
commit 11a39a53cb
2 changed files with 8 additions and 2 deletions
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"log"
"net/http"
"strings"
"text/template"
"time"
@@ -220,7 +219,7 @@ func editorPost(w http.ResponseWriter, r *http.Request) {
return
}
if newBlog.ID == "" {
newBlog.ID = strings.TrimSpace(strings.ToLower(strings.ReplaceAll(newBlog.Title, " ", "-")))
newBlog.ID = newBlog.IDFromTitle()
if blogApp.Contains(r.Context(), newBlog.ID) {
sendContent(w, r, "<p>Title is not unique!</p>", "", "")
return