mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-12-20 16:41:16 +00:00
[#1] Allow URI encoded slash in badge fields
Fixes `/static/test/branch%2Fname` to result in `[ test | branch ]` badge Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
499355a617
commit
53f2261a84
1 changed files with 9 additions and 1 deletions
10
app.go
10
app.go
|
@ -115,7 +115,7 @@ func main() {
|
|||
log.Printf("Loaded %d value pairs into configuration store", len(configStore))
|
||||
}
|
||||
|
||||
r := mux.NewRouter()
|
||||
r := mux.NewRouter().UseEncodedPath()
|
||||
r.HandleFunc("/v1/badge", generateBadge).Methods("GET")
|
||||
r.HandleFunc("/{service}/{parameters:.*}", generateServiceBadge).Methods("GET")
|
||||
r.HandleFunc("/", handleDemoPage)
|
||||
|
@ -126,7 +126,15 @@ func main() {
|
|||
func generateServiceBadge(res http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
service := vars["service"]
|
||||
|
||||
var err error
|
||||
params := strings.Split(vars["parameters"], "/")
|
||||
for i := range params {
|
||||
if params[i], err = url.QueryUnescape(params[i]); err != nil {
|
||||
http.Error(res, "Invalid escaping in URL", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
al := accessLogger.New(res)
|
||||
|
||||
|
|
Loading…
Reference in a new issue