mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-18 08:20:53 +00:00
style: modify override schema
info and provider parse error message
This commit is contained in:
parent
35ae51daad
commit
061ac5efde
2 changed files with 6 additions and 6 deletions
|
@ -29,9 +29,9 @@ type healthCheckSchema struct {
|
|||
|
||||
type OverrideProxyNameSchema struct {
|
||||
// matching expression for regex replacement
|
||||
Pattern string `provider:"pattern,omitempty"`
|
||||
Pattern string `provider:"pattern"`
|
||||
// the new content after regex matching
|
||||
Target string `provider:"target,omitempty"`
|
||||
Target string `provider:"target"`
|
||||
}
|
||||
|
||||
type OverrideSchema struct {
|
||||
|
@ -49,7 +49,7 @@ type OverrideSchema struct {
|
|||
AdditionalPrefix *string `provider:"additional-prefix,omitempty"`
|
||||
AdditionalSuffix *string `provider:"additional-suffix,omitempty"`
|
||||
|
||||
ProxyName []*OverrideProxyNameSchema `provider:"proxy-name,omitempty"`
|
||||
ProxyName []OverrideProxyNameSchema `provider:"proxy-name,omitempty"`
|
||||
}
|
||||
|
||||
type proxyProviderSchema struct {
|
||||
|
|
|
@ -400,9 +400,9 @@ func proxiesParseAndFilter(filter string, excludeFilter string, excludeTypeArray
|
|||
name := mapping["name"].(string)
|
||||
mapping["name"] = name + *field.Interface().(*string)
|
||||
case "proxy-name":
|
||||
exprList, ok := field.Interface().([]*OverrideProxyNameSchema)
|
||||
exprList, ok := field.Interface().([]OverrideProxyNameSchema)
|
||||
if !ok {
|
||||
return nil, errors.New("file must have a `proxy-name` field")
|
||||
return nil, fmt.Errorf("can't parse proxy-provider override proxy-name, please see the docs example config")
|
||||
}
|
||||
// Iterate through all naming replacement rules and perform the replacements.
|
||||
for _, expr := range exprList {
|
||||
|
@ -413,7 +413,7 @@ func proxiesParseAndFilter(filter string, excludeFilter string, excludeTypeArray
|
|||
}
|
||||
newName, err := nameReg.Replace(name, expr.Target, 0, -1)
|
||||
if err != nil {
|
||||
return nil, errors.New("proxy name replace error")
|
||||
return nil, fmt.Errorf("proxy name replace error: %w", err)
|
||||
}
|
||||
mapping["name"] = newName
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue