Skip to content

Commit

Permalink
fix: Make the ruleset take effect in a single line
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Jun 28, 2024
1 parent f45ccc0 commit 0e22876
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rules/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"bytes"
"encoding/json"
"errors"
"gopkg.in/yaml.v3"
"runtime"
"strings"
"time"

"gopkg.in/yaml.v3"

"github.com/metacubex/mihomo/common/pool"
"github.com/metacubex/mihomo/component/resource"
C "github.com/metacubex/mihomo/constant"
Expand Down Expand Up @@ -170,15 +171,14 @@ func rulesParse(buf []byte, strategy ruleStrategy, format P.RuleFormat) (ruleStr
line = buf[s : i+1]
s = i + 1
} else {
s = len(buf) // stop loop in next step
if firstLineLength == 0 { // no head or only one line body
s = len(buf) // stop loop in next step
if firstLineLength == 0 && format == P.YamlRule { // no head or only one line body
return nil, ErrNoPayload
}
}
var str string
switch format {
case P.TextRule:
firstLineLength = -1 // don't return ErrNoPayload when read last line
str = string(line)
str = strings.TrimSpace(str)
if len(str) == 0 {
Expand Down

0 comments on commit 0e22876

Please sign in to comment.