add help messages to rules, updat url validation

This commit is contained in:
yusing
2025-01-09 13:49:15 +08:00
parent 4aee44fe11
commit 9d701ad671
4 changed files with 126 additions and 8 deletions

View File

@@ -35,6 +35,23 @@ func validateURL(args []string) (any, E.Error) {
return u, nil
}
func validateAbsoluteURL(args []string) (any, E.Error) {
if len(args) != 1 {
return nil, ErrExpectOneArg
}
u, err := types.ParseURL(args[0])
if err != nil {
return nil, ErrInvalidArguments.With(err)
}
if u.Scheme == "" {
u.Scheme = "http"
}
if u.Host == "" {
return nil, ErrInvalidArguments.Withf("missing host")
}
return u, nil
}
func validateCIDR(args []string) (any, E.Error) {
if len(args) != 1 {
return nil, ErrExpectOneArg