Allow external redirects for 3xx statuses

Fixes #60
This commit is contained in:
David Leadbeater
2025-11-17 19:24:54 +11:00
parent 5a09d30d3d
commit 3334af922f
+7 -5
View File
@@ -74,11 +74,13 @@ func validateRedirectRule(rule redirects.Rule) error {
if err != nil {
return fmt.Errorf("malformed 'to' URL")
}
if !strings.HasPrefix(toURL.Path, "/") {
return fmt.Errorf("'to' URL path must start with a /")
}
if toURL.Host != "" && !Is3xxHTTPStatus(uint(rule.Status)) {
return fmt.Errorf("'to' URL may only include a hostname for 3xx status rules")
if !Is3xxHTTPStatus(uint(rule.Status)) {
if !strings.HasPrefix(toURL.Path, "/") {
return fmt.Errorf("'to' URL path must start with a / for non-3xx status rules")
}
if toURL.Host != "" {
return fmt.Errorf("'to' URL may only include a hostname for 3xx status rules")
}
}
return nil
}