Fix location of pref hosts injection
This commit is contained in:
@@ -3,7 +3,6 @@ package universal
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -151,18 +150,5 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
||||
}
|
||||
|
||||
func redirect(resp http.ResponseWriter, req *http.Request, url string, cfg config.ConfigInterface) {
|
||||
prefHost := cfg.GetRandomPreferredHost()
|
||||
if prefHost != "" {
|
||||
url = replaceHostInURL(url, prefHost)
|
||||
}
|
||||
http.Redirect(resp, req, url, http.StatusFound)
|
||||
}
|
||||
|
||||
func replaceHostInURL(inputURL string, newHost string) string {
|
||||
u, err := url.Parse(inputURL)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
u.Host = newHost
|
||||
return u.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user