From 04fd5ac63aa208f79584da6314039a19dd8b158d Mon Sep 17 00:00:00 2001 From: Sam Rolfe Date: Mon, 10 Aug 2026 16:54:10 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20legacy=20QR=20URLs=20without=20'=3F'=20(?= =?UTF-8?q?productid=20in=20path)=20redirect=20to=20/t/CODE=20(new=20tag?= =?UTF-8?q?=2097=20now=20scans);=20preview=20page=20photo=20portrait=20asp?= =?UTF-8?q?ect;=20Preview=20button=20on=20user=20tags=20list;=20admin=20ph?= =?UTF-8?q?oto=20form=20=3D=20preview=20+=20standalone=20Upload=20button?= =?UTF-8?q?=20(removed=20URL=20TextInput=20=E2=80=94=20no=20duplicate,=20n?= =?UTF-8?q?o=20stale=20placeholder)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/internal/handlers/legacy.go | 21 +++++++++++++++++++++ frontend/main.go | 2 +- frontend/templates/tag-list.html | 1 + frontend/templates/tag-public.html | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 frontend/internal/handlers/legacy.go 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 @@
{{if .Data.PhotoUrl.Valid}} - Item photo + Item photo {{end}} {{if .Data.Description.Valid}}

{{.Data.Description.String}}