mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-24 05:02:14 +08:00
fix: Make the ruleset take effect in a single line
This commit is contained in:
parent
f45ccc0761
commit
0e228765fc
@ -4,11 +4,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/common/pool"
|
"github.com/metacubex/mihomo/common/pool"
|
||||||
"github.com/metacubex/mihomo/component/resource"
|
"github.com/metacubex/mihomo/component/resource"
|
||||||
C "github.com/metacubex/mihomo/constant"
|
C "github.com/metacubex/mihomo/constant"
|
||||||
@ -171,14 +172,13 @@ func rulesParse(buf []byte, strategy ruleStrategy, format P.RuleFormat) (ruleStr
|
|||||||
s = i + 1
|
s = i + 1
|
||||||
} else {
|
} else {
|
||||||
s = len(buf) // stop loop in next step
|
s = len(buf) // stop loop in next step
|
||||||
if firstLineLength == 0 { // no head or only one line body
|
if firstLineLength == 0 && format == P.YamlRule { // no head or only one line body
|
||||||
return nil, ErrNoPayload
|
return nil, ErrNoPayload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var str string
|
var str string
|
||||||
switch format {
|
switch format {
|
||||||
case P.TextRule:
|
case P.TextRule:
|
||||||
firstLineLength = -1 // don't return ErrNoPayload when read last line
|
|
||||||
str = string(line)
|
str = string(line)
|
||||||
str = strings.TrimSpace(str)
|
str = strings.TrimSpace(str)
|
||||||
if len(str) == 0 {
|
if len(str) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user