mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Support multiple values for to
in simple rule.
This commit is contained in:
parent
55f69fd742
commit
3468986260
2 changed files with 6 additions and 6 deletions
|
@ -40,9 +40,6 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
|
|||
var ifs []rewrite.If
|
||||
|
||||
switch len(args) {
|
||||
case 2:
|
||||
rule = rewrite.NewSimpleRule(args[0], args[1])
|
||||
simpleRules = append(simpleRules, rule)
|
||||
case 1:
|
||||
base = args[0]
|
||||
fallthrough
|
||||
|
@ -88,8 +85,11 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
|
|||
return nil, err
|
||||
}
|
||||
regexpRules = append(regexpRules, rule)
|
||||
|
||||
// the only unhandled case is 2 and above
|
||||
default:
|
||||
return nil, c.ArgErr()
|
||||
rule = rewrite.NewSimpleRule(args[0], strings.Join(args[1:], " "))
|
||||
simpleRules = append(simpleRules, rule)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ func TestRewriteParse(t *testing.T) {
|
|||
}},
|
||||
{`rewrite a`, true, []rewrite.Rule{}},
|
||||
{`rewrite`, true, []rewrite.Rule{}},
|
||||
{`rewrite a b c`, true, []rewrite.Rule{
|
||||
rewrite.SimpleRule{From: "a", To: "b"},
|
||||
{`rewrite a b c`, false, []rewrite.Rule{
|
||||
rewrite.SimpleRule{From: "a", To: "b c"},
|
||||
}},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue