Commit 34689862 authored by Abiola Ibrahim's avatar Abiola Ibrahim

Support multiple values for `to` in simple rule.

parent 55f69fd7
...@@ -40,9 +40,6 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) { ...@@ -40,9 +40,6 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
var ifs []rewrite.If var ifs []rewrite.If
switch len(args) { switch len(args) {
case 2:
rule = rewrite.NewSimpleRule(args[0], args[1])
simpleRules = append(simpleRules, rule)
case 1: case 1:
base = args[0] base = args[0]
fallthrough fallthrough
...@@ -88,8 +85,11 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) { ...@@ -88,8 +85,11 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
return nil, err return nil, err
} }
regexpRules = append(regexpRules, rule) regexpRules = append(regexpRules, rule)
// the only unhandled case is 2 and above
default: 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) { ...@@ -50,8 +50,8 @@ func TestRewriteParse(t *testing.T) {
}}, }},
{`rewrite a`, true, []rewrite.Rule{}}, {`rewrite a`, true, []rewrite.Rule{}},
{`rewrite`, true, []rewrite.Rule{}}, {`rewrite`, true, []rewrite.Rule{}},
{`rewrite a b c`, true, []rewrite.Rule{ {`rewrite a b c`, false, []rewrite.Rule{
rewrite.SimpleRule{From: "a", To: "b"}, rewrite.SimpleRule{From: "a", To: "b c"},
}}, }},
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment