Skip to content

Commit 0b3cefe

Browse files
committed
deal with unslashed static
1 parent 744c574 commit 0b3cefe

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

serve/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"os"
88
"strconv"
9+
"strings"
910

1011
"github.com/julienschmidt/httprouter"
1112
)
@@ -46,6 +47,9 @@ func main() {
4647
func mux(static string, score ScoreHandler) *httprouter.Router {
4748
r := httprouter.New()
4849
if static != "" {
50+
if !strings.HasSuffix(static, "/") {
51+
static += "/"
52+
}
4953
r.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
5054
http.ServeFile(w, r, static+"index.html")
5155
})

0 commit comments

Comments
 (0)