diff --git a/router.go b/router.go index 289a515..a6e4e5b 100755 --- a/router.go +++ b/router.go @@ -104,7 +104,7 @@ func (router *Router) validateRoute(path string) error { } // path must not end with a slash - if path[len(path)-1] == '/' { + if len(path) > 1 && path[len(path)-1] == '/' { return fmt.Errorf("URL path must not end with a slash (/)") } diff --git a/router_test.go b/router_test.go index 2534072..c085142 100755 --- a/router_test.go +++ b/router_test.go @@ -82,7 +82,7 @@ func TestRouterServerHandler(t *testing.T) { testHandler := TestHandler{CloseChannel: make(chan bool, 2)} router := New() - router.Handle(http.MethodGet, "/home", testHandler) + router.Handle(http.MethodGet, "/", testHandler) listener, err := net.Listen("tcp", "localhost:8081") if err != nil { t.Error(err) @@ -90,7 +90,7 @@ func TestRouterServerHandler(t *testing.T) { go http.Serve(listener, router) // call method - _, err = http.Get("http://localhost:8081/home") + _, err = http.Get("http://localhost:8081/") if err != nil { t.Error(err) }