mirror of
https://github.com/bestnite/sub2clash.git
synced 2025-06-17 20:53:18 +08:00
update regex to dynamically include all supported prefixes for improved proxy parsing.
This commit is contained in:
@ -148,7 +148,11 @@ func BuildSub(clashType model.ClashType, query model.SubConfig, template string,
|
||||
err = yaml.Unmarshal(data, &sub)
|
||||
var newProxies []P.Proxy
|
||||
if err != nil {
|
||||
reg, _ := regexp.Compile("(ssr|ss|vmess|trojan|vless|hysteria|hy2|hysteria2|socks)://")
|
||||
reg, err := regexp.Compile("(" + strings.Join(parser.GetAllPrefixes(), "|") + ")://")
|
||||
if err != nil {
|
||||
logger.Logger.Debug("compile regex failed", zap.Error(err))
|
||||
return nil, NewRegexInvalidError("prefix", err)
|
||||
}
|
||||
if reg.Match(data) {
|
||||
p := parser.ParseProxies(strings.Split(string(data), "\n")...)
|
||||
newProxies = p
|
||||
|
Reference in New Issue
Block a user