html debug page: make spew output mangling more precise
Previously, it also ate anything in parens in string literals, such as in “Donation (200 CHF)”!
This commit is contained in:
@@ -30,7 +30,7 @@ import (
|
||||
var (
|
||||
fieldNameRe = regexp.MustCompile(`<br>( )*([^:]+):`)
|
||||
stringLiteralRe = regexp.MustCompile(`"([^"]*)"`)
|
||||
parenRe = regexp.MustCompile(`\(([^)]+)\) `)
|
||||
typeInfoRe = regexp.MustCompile(`(<br>( )*([^:]+): )[^"{]+`)
|
||||
)
|
||||
|
||||
var tmpl = template.Must(template.New("").Parse(`<!DOCTYPE html>
|
||||
@@ -203,7 +203,7 @@ func debugHTML(w http.ResponseWriter, r *http.Request, prefix string, qrch *qrbi
|
||||
sp := spew.Sdump(vars...)
|
||||
sp = strings.ReplaceAll(sp, "\n", "<br>")
|
||||
sp = strings.ReplaceAll(sp, " ", " ")
|
||||
sp = parenRe.ReplaceAllString(sp, "")
|
||||
sp = typeInfoRe.ReplaceAllString(sp, "$1")
|
||||
sp = stringLiteralRe.ReplaceAllStringFunc(sp, func(stringLiteral string) string {
|
||||
return `<span class="stringliteral">` + stringLiteral + "</span>"
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user