Properly form a download URL.
This commit is contained in:
parent
c884fe8225
commit
4a5f54ee70
@ -14,6 +14,7 @@ import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -174,16 +175,18 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
downloadURL := path.Join("/f", fSaltedHash, fHandler.Filename)
|
||||
downloadURLParsed, _ := url.Parse(downloadURL)
|
||||
|
||||
if strings.Contains(r.UserAgent(), "curl") {
|
||||
_, scheme := utils.NetworkType(r.Host)
|
||||
w.Write([]byte(path.Join(scheme, "://", r.Host, downloadURL) + "\r\n"))
|
||||
downloadURL = fmt.Sprint(scheme, "://", r.Host, downloadURLParsed, "\r\n")
|
||||
w.Write([]byte(downloadURL))
|
||||
return
|
||||
}
|
||||
|
||||
if err := compiledTemplates["uploaded"].Execute(w, &UploadedData{
|
||||
MainSite: utils.MainSite(r.Host),
|
||||
DownloadURL: downloadURL,
|
||||
DownloadURL: downloadURLParsed.String(),
|
||||
KeepForHours: h.conf.Uploads.Limits.KeepForHours,
|
||||
}); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
Loading…
Reference in New Issue
Block a user