Skip to content

Commit f97be82

Browse files
committed
clean-up
1 parent 51c2bc7 commit f97be82

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = 1.2.1
1+
VERSION = 1.2.2
22

33
APP := http-file-server
44
PACKAGES := $(shell go list -f {{.Dir}} ./...)

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ Or [download a binary](https://github.com/sgreben/http-file-server/releases/late
6060

6161
```sh
6262
# 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
6464

6565
# 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
6767

6868
# 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
7171
```
7272

7373
## Use it

main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ func server(addr string, routes routes) error {
8888
log.Printf("serving local path %q on %q", path, route)
8989
}
9090

91-
if _, ok := handlers[rootRoute]; !ok && len(routes.Values) > 0 {
91+
_, rootRouteTaken := handlers[rootRoute]
92+
if !rootRouteTaken {
9293
route := routes.Values[0].Route
9394
mux.Handle(rootRoute, http.RedirectHandler(route, http.StatusTemporaryRedirect))
9495
log.Printf("redirecting to %q from %q", route, rootRoute)

routes.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ func (fv *routes) Set(v string) error {
3232
}
3333
i := strings.Index(v, separator)
3434
var route, path string
35+
var err error
3536
if i <= 0 {
3637
path = strings.TrimPrefix(v, "=")
37-
var err error
3838
path, err = filepath.Abs(path)
3939
if err != nil {
4040
return err
@@ -43,6 +43,10 @@ func (fv *routes) Set(v string) error {
4343
} else {
4444
route = v[:i]
4545
path = v[i+len(separator):]
46+
path, err = filepath.Abs(path)
47+
if err != nil {
48+
return err
49+
}
4650
if !strings.HasPrefix(route, "/") {
4751
route = "/" + route
4852
}

0 commit comments

Comments
 (0)