Commit eea68c34 authored by Maxime's avatar Maxime

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.
parent 8a2d0890
......@@ -23,9 +23,9 @@ func (rd Redirect) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
for _, rule := range rd.Rules {
if rule.From == "/" {
// Catchall redirect preserves path (TODO: Standardize/formalize this behavior)
toURL, err := url.ParseRequestURI(rule.To)
toURL, err := url.Parse(rule.To)
if err != nil {
return 500, err
return http.StatusInternalServerError, err
}
newPath := toURL.Host + toURL.Path + r.URL.Path
rmSlashs := regexp.MustCompile("//+")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment