0
Fork 0
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:
Abiola Ibrahim 2015-12-31 20:11:31 +01:00
parent 55f69fd742
commit 3468986260
2 changed files with 6 additions and 6 deletions

View file

@ -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)
}
}

View file

@ -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"},
}},
}