Fixed bad URL redirect bug
This commit is contained in:
parent
0216358dfb
commit
01ef0d5183
@ -47,6 +47,7 @@ func (ctx *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
id, err := qurl.FromString(fname[1:len(fname)])
|
id, err := qurl.FromString(fname[1:len(fname)])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
q, err := ctx.Storage.GetQURLByID(id)
|
q, err := ctx.Storage.GetQURLByID(id)
|
||||||
@ -56,6 +57,11 @@ func (ctx *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q == nil {
|
||||||
|
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, q.URL, http.StatusPermanentRedirect)
|
http.Redirect(w, r, q.URL, http.StatusPermanentRedirect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user