Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddyfile: Fix bug with Delete
It now will delete the current token even if it is the last one
Matthew Holt committed
Nov 4, 2019 at 13:25 UTC
263ffbfaecc5ed8b7f5071baecf51b4e9d90e7bf
2 files changed
+3
-2
caddyconfig/caddyfile/dispenser.go
+1
-1
@@ -339,7 +339,7 @@ func (d *Dispenser) Errf(format string, args ...interface{}) error {
339
// array will become apparent (or worse, hide from you like they
340
// did me for 3 and a half freaking hours late one night).
341
func (d *Dispenser) Delete() []Token {
342
- if d.cursor >= 0 && d.cursor < len(d.tokens)-1 {
342
+ if d.cursor >= 0 && d.cursor <= len(d.tokens)-1 {
343
d.tokens = append(d.tokens[:d.cursor], d.tokens[d.cursor+1:]...)
344
d.cursor--
345
}
caddyconfig/httpcaddyfile/directives.go
+2
-1
@@ -64,7 +64,8 @@ func RegisterHandlerDirective(dir string, setupFunc UnmarshalHandlerFunc) {
64
return nil, err
65
}
66
if ok {
67
- h.Dispenser.Delete() // strip matcher token
67
+ tokens := h.Dispenser.Delete() // strip matcher token
68
+ h.Dispenser = caddyfile.NewDispenser(tokens)
69
}
70
71
h.Dispenser.Reset() // pretend this lookahead never happened