diff --git a/rules/provider/classical_strategy.go b/rules/provider/classical_strategy.go index 2fc52090..430acead 100644 --- a/rules/provider/classical_strategy.go +++ b/rules/provider/classical_strategy.go @@ -4,6 +4,7 @@ import ( "fmt" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" + "strings" ) type classicalStrategy struct { @@ -52,6 +53,19 @@ func (c *classicalStrategy) OnUpdate(rules []string) { c.count = len(classicalRules) } +func ruleParse(ruleRaw string) (string, string, []string) { + item := strings.Split(ruleRaw, ",") + if len(item) == 1 { + return "", item[0], nil + } else if len(item) == 2 { + return item[0], item[1], nil + } else if len(item) > 2 { + return item[0], item[1], item[2:] + } + + return "", "", nil +} + func NewClassicalStrategy(parse func(tp, payload, target string, params []string) (parsed C.Rule, parseErr error)) *classicalStrategy { return &classicalStrategy{rules: []C.Rule{}, parse: func(tp, payload, target string, params []string) (parsed C.Rule, parseErr error) { switch tp { diff --git a/rules/provider/domain_strategy.go b/rules/provider/domain_strategy.go index d78bb44c..9b1a49af 100644 --- a/rules/provider/domain_strategy.go +++ b/rules/provider/domain_strategy.go @@ -4,7 +4,6 @@ import ( "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" - "strings" ) type domainStrategy struct { @@ -40,19 +39,6 @@ func (d *domainStrategy) OnUpdate(rules []string) { d.count = count } -func ruleParse(ruleRaw string) (string, string, []string) { - item := strings.Split(ruleRaw, ",") - if len(item) == 1 { - return "", item[0], nil - } else if len(item) == 2 { - return item[0], item[1], nil - } else if len(item) > 2 { - return item[0], item[1], item[2:] - } - - return "", "", nil -} - func NewDomainStrategy() *domainStrategy { return &domainStrategy{} }