aboutsummaryrefslogtreecommitdiffhomepage
path: root/replacer.go
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2020-02-25 22:00:33 -0700
committerGitHub <[email protected]>2020-02-25 22:00:33 -0700
commit5d97522d18da39cd3f9dd309774a5ad2c51f4c51 (patch)
tree8d90c0200edbf2f252a7d57c6f65255a0e38b9e0 /replacer.go
parentf6b9cb7122c670ae063a9049455ec99edf0dc8be (diff)
downloadcaddy-5d97522d18da39cd3f9dd309774a5ad2c51f4c51.tar.gz
caddy-5d97522d18da39cd3f9dd309774a5ad2c51f4c51.zip
v2: 'log' directive for Caddyfile, and debug mode (#3052)
* httpcaddyfile: Begin implementing log directive, and debug mode For now, debug mode just sets the log level for all logs to DEBUG (unless a level is specified explicitly). * httpcaddyfile: Finish 'log' directive Also rename StringEncoder -> SingleFieldEncoder * Fix minor bug in replacer (when vals are empty)
Diffstat (limited to 'replacer.go')
-rw-r--r--replacer.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/replacer.go b/replacer.go
index 8ed6d2495..aad13e2a2 100644
--- a/replacer.go
+++ b/replacer.go
@@ -148,11 +148,10 @@ func (r *Replacer) replace(input, empty string,
if errOnUnknown {
return "", fmt.Errorf("unrecognized placeholder %s%s%s",
string(phOpen), key, string(phClose))
- } else if treatUnknownAsEmpty {
- if empty != "" {
- sb.WriteString(empty)
- }
- } else {
+ } else if !treatUnknownAsEmpty {
+ // if treatUnknownAsEmpty is true, we'll
+ // handle an empty val later; so only
+ // continue otherwise
lastWriteCursor = i
continue
}