mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-20 22:52:58 -05:00
Changes regarding comment.
Used http status code instead of a hardcoded value. Used url.Parse instead of url.ParseRequestURI, so that you can parse both absolute and relative URL.
This commit is contained in:
parent
8a2d0890a2
commit
eea68c34ad
1 changed files with 2 additions and 2 deletions
|
@ -23,9 +23,9 @@ func (rd Redirect) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
|
||||||
for _, rule := range rd.Rules {
|
for _, rule := range rd.Rules {
|
||||||
if rule.From == "/" {
|
if rule.From == "/" {
|
||||||
// Catchall redirect preserves path (TODO: Standardize/formalize this behavior)
|
// Catchall redirect preserves path (TODO: Standardize/formalize this behavior)
|
||||||
toURL, err := url.ParseRequestURI(rule.To)
|
toURL, err := url.Parse(rule.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 500, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
newPath := toURL.Host + toURL.Path + r.URL.Path
|
newPath := toURL.Host + toURL.Path + r.URL.Path
|
||||||
rmSlashs := regexp.MustCompile("//+")
|
rmSlashs := regexp.MustCompile("//+")
|
||||||
|
|
Loading…
Add table
Reference in a new issue