From 3334af922f00c1a854a963e42cd5dd66e1d6780f Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Mon, 17 Nov 2025 19:24:54 +1100 Subject: [PATCH] Allow external redirects for 3xx statuses Fixes #60 --- src/redirects.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/redirects.go b/src/redirects.go index 223f9fe..898182c 100644 --- a/src/redirects.go +++ b/src/redirects.go @@ -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 }