package web import ( "fmt" "net/http" "strings" ) func queryOrDefault(r *http.Request, key, fallback string) string { if value := r.URL.Query().Get(key); value != "" { return value } return fallback } func syncNotice(r *http.Request) string { imported := r.URL.Query().Get("imported") if imported == "" { return "" } return fmt.Sprintf("Sync complete: %s imported, %s skipped.", imported, r.URL.Query().Get("skipped")) } func rideDetailNotice(r *http.Request) string { if r.URL.Query().Get("official_climb") == "created" { return "Official climb saved and matched to this ride by coordinates." } if r.URL.Query().Get("categories") == "updated" { return "Ride categories updated." } return "" } func safeReturnTo(value string) string { if value == "" || !strings.HasPrefix(value, "/") || strings.HasPrefix(value, "//") { return "/sync" } return value }