diff --git a/frontend/internal/handlers/legacy.go b/frontend/internal/handlers/legacy.go new file mode 100644 index 0000000..fb010a6 --- /dev/null +++ b/frontend/internal/handlers/legacy.go @@ -0,0 +1,21 @@ +package handlers + +import ( + "net/http" + "strings" +) + +// LegacyNotFound handles old printed QR URLs of the form +// https://where-woof.com/x=5&productid=CODE (no '?' before productid — +// the whole thing lands in the path). Redirects to /t/CODE. +func (a *App) LegacyNotFound(w http.ResponseWriter, r *http.Request) { + path := r.URL.Path + if i := strings.Index(path, "productid="); i >= 0 { + code := path[i+len("productid="):] + if code != "" { + http.Redirect(w, r, "/t/"+code, http.StatusFound) + return + } + } + http.NotFound(w, r) +} diff --git a/frontend/main.go b/frontend/main.go index f6d207f..393e85a 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -70,7 +70,7 @@ func main() { mux.HandleFunc("GET /about", app.About) mux.HandleFunc("GET /what-is-this", app.WhatIsThis) mux.HandleFunc("GET /contact", app.Contact) - mux.HandleFunc("/{path...}", http.NotFound) + mux.HandleFunc("/{path...}", app.LegacyNotFound) mux.HandleFunc("GET /t/{tag_code}", app.PublicTag) mux.HandleFunc("GET /s/{code}", app.ServeShort) mux.HandleFunc("POST /t/{tag_code}/scan", app.Scan) diff --git a/frontend/templates/tag-list.html b/frontend/templates/tag-list.html index 4e3ede1..df5d71d 100644 --- a/frontend/templates/tag-list.html +++ b/frontend/templates/tag-list.html @@ -25,6 +25,7 @@ {{if ne .Status "closed"}} Edit {{end}} + Preview
diff --git a/frontend/templates/tag-public.html b/frontend/templates/tag-public.html index f06ea11..348cf70 100644 --- a/frontend/templates/tag-public.html +++ b/frontend/templates/tag-public.html @@ -40,7 +40,7 @@{{.Data.Description.String}}