diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/http.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/http/http.go b/src/http/http.go index dc23037..5593969 100644 --- a/src/http/http.go +++ b/src/http/http.go @@ -136,9 +136,13 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { if query["download"] != nil { // strip the file before and after the request - strippedFile := strings.Replace(requestURI, root, "", -1) - strippedFile = strings.Replace(strippedFile, "?download", "", -1) - path := fmt.Sprintf("/download?file=%s", strippedFile) + strippedFile := strings.Replace(requestPath, root, "", -1) + + // base64 encode the file path + strippedFileBase64 := base64.StdEncoding.EncodeToString([]byte(strippedFile)) + + // redirect to the /download handler with the file path and the salted hash + path := fmt.Sprintf("/download?file=%s&hash=%s", strippedFileBase64, query["hash"][0]) http.Redirect(w, r, path, http.StatusSeeOther) return } |