22 lines
538 B
Go
22 lines
538 B
Go
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)
|
|
}
|