mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
fix rewrite omitting trailing slash, error msg update
This commit is contained in:
@@ -54,10 +54,14 @@ func validateURLPath(args []string) (any, E.Error) {
|
||||
return nil, ErrExpectOneArg
|
||||
}
|
||||
p := args[0]
|
||||
trailingSlash := len(p) > 1 && p[len(p)-1] == '/'
|
||||
p, _, _ = strings.Cut(p, "#")
|
||||
p = path.Clean(p)
|
||||
if len(p) == 0 {
|
||||
return "/", nil
|
||||
return nil, ErrInvalidArguments.Withf("empty path")
|
||||
}
|
||||
if trailingSlash {
|
||||
p += "/"
|
||||
}
|
||||
if p[0] != '/' {
|
||||
return nil, ErrInvalidArguments.Withf("must start with /")
|
||||
|
||||
Reference in New Issue
Block a user