Skip to content

Commit e22e277

Browse files
committed
Updated to v2
1 parent 0e479d4 commit e22e277

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/onattech/toolkit
1+
module github.com/onattech/toolkit/v2
22

33
go 1.19

tools.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"io"
1010
"net/http"
1111
"os"
12-
"path"
1312
"path/filepath"
1413
"regexp"
1514
"strings"
@@ -189,11 +188,10 @@ func (t *Tools) Slugify(s string) (string, error) {
189188
// DownloadStaticFile downloads a file, and tries to force the browser to avoid displaying it
190189
// in the browser window by setting content disposition. It also allows specification of the
191190
// display name
192-
func (t *Tools) DownloadStaticFile(w http.ResponseWriter, r *http.Request, p, file, displayName string) {
193-
fp := path.Join(p, file)
191+
func (t *Tools) DownloadStaticFile(w http.ResponseWriter, r *http.Request, pathName, displayName string) {
194192
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", displayName))
195193

196-
http.ServeFile(w, r, fp)
194+
http.ServeFile(w, r, pathName)
197195
}
198196

199197
// JSONResponse is the type used for sending JSON around

tools_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func TestTools_DownloadStaticFile(t *testing.T) {
235235

236236
var testTool Tools
237237

238-
testTool.DownloadStaticFile(rr, req, "./testdata", "pic.jpg", "moon.jpg")
238+
testTool.DownloadStaticFile(rr, req, "./testdata/pic.jpg", "moon.jpg")
239239

240240
res := rr.Result()
241241
defer res.Body.Close()

0 commit comments

Comments
 (0)