blob: 43eee486aa0fa0b47f465a299f4c4980ba8fbfd2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
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
}
|