Nomalize url before redirecting.

This commit is contained in:
chrislusf
2015-04-16 10:02:53 -07:00
parent 67146ffa78
commit 087b839354
3 changed files with 10 additions and 2 deletions

View File

@@ -123,7 +123,7 @@ func (ms *MasterServer) redirectHandler(w http.ResponseWriter, r *http.Request)
}
machines := ms.Topo.Lookup("", volumeId)
if machines != nil && len(machines) > 0 {
http.Redirect(w, r, "http://"+machines[rand.Intn(len(machines))].PublicUrl+r.URL.Path, http.StatusMovedPermanently)
http.Redirect(w, r, util.NormalizeUrl(machines[rand.Intn(len(machines))].PublicUrl)+r.URL.Path, http.StatusMovedPermanently)
} else {
writeJsonError(w, r, http.StatusNotFound, fmt.Errorf("volume id %d not found", volumeId))
}