File tree 4 files changed +12
-7
lines changed
4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 1
- VERSION = 1.2.1
1
+ VERSION = 1.2.2
2
2
3
3
APP := http-file-server
4
4
PACKAGES := $(shell go list -f {{.Dir}} ./...)
Original file line number Diff line number Diff line change @@ -60,14 +60,14 @@ Or [download a binary](https://github.com/sgreben/http-file-server/releases/late
60
60
61
61
``` sh
62
62
# Linux
63
- curl -L https://github.com/sgreben/http-file-server/releases/download/1.2.1 /http-file-server_1.2.1_linux_x86_64 .tar.gz | tar xz
63
+ curl -L https://github.com/sgreben/http-file-server/releases/download/1.2.2 /http-file-server_1.2.2_linux_x86_64 .tar.gz | tar xz
64
64
65
65
# OS X
66
- curl -L https://github.com/sgreben/http-file-server/releases/download/1.2.1 /http-file-server_1.2.1_osx_x86_64 .tar.gz | tar xz
66
+ curl -L https://github.com/sgreben/http-file-server/releases/download/1.2.2 /http-file-server_1.2.2_osx_x86_64 .tar.gz | tar xz
67
67
68
68
# Windows
69
- curl -LO https://github.com/sgreben/http-file-server/releases/download/1.2.1 /http-file-server_1.2.1_windows_x86_64 .zip
70
- unzip versions_1.2.1_windows_x86_64 .zip
69
+ curl -LO https://github.com/sgreben/http-file-server/releases/download/1.2.2 /http-file-server_1.2.2_windows_x86_64 .zip
70
+ unzip versions_1.2.2_windows_x86_64 .zip
71
71
```
72
72
73
73
## Use it
Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ func server(addr string, routes routes) error {
88
88
log .Printf ("serving local path %q on %q" , path , route )
89
89
}
90
90
91
- if _ , ok := handlers [rootRoute ]; ! ok && len (routes .Values ) > 0 {
91
+ _ , rootRouteTaken := handlers [rootRoute ]
92
+ if ! rootRouteTaken {
92
93
route := routes .Values [0 ].Route
93
94
mux .Handle (rootRoute , http .RedirectHandler (route , http .StatusTemporaryRedirect ))
94
95
log .Printf ("redirecting to %q from %q" , route , rootRoute )
Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ func (fv *routes) Set(v string) error {
32
32
}
33
33
i := strings .Index (v , separator )
34
34
var route , path string
35
+ var err error
35
36
if i <= 0 {
36
37
path = strings .TrimPrefix (v , "=" )
37
- var err error
38
38
path , err = filepath .Abs (path )
39
39
if err != nil {
40
40
return err
@@ -43,6 +43,10 @@ func (fv *routes) Set(v string) error {
43
43
} else {
44
44
route = v [:i ]
45
45
path = v [i + len (separator ):]
46
+ path , err = filepath .Abs (path )
47
+ if err != nil {
48
+ return err
49
+ }
46
50
if ! strings .HasPrefix (route , "/" ) {
47
51
route = "/" + route
48
52
}
You can’t perform that action at this time.
0 commit comments