From 7f419b0c2c86eb0b8c711b47392998e33e34bf9d Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 8 May 2013 21:13:43 -0700 Subject: Clean up messy path before matching a request. Try to clean up messy path (too many slashes for now) in the path before applying the Match. --- router_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'router_test.go') diff --git a/router_test.go b/router_test.go index cb18fba..71fdcaf 100644 --- a/router_test.go +++ b/router_test.go @@ -2,6 +2,8 @@ package router import ( "github.com/franckcuny/web-request" + "net/http" + "net/url" "testing" ) @@ -142,3 +144,14 @@ func TestAddNotAllowed(t *testing.T) { t.Fatal() } } + +func TestMessyPath(t *testing.T) { + r := BuildRouter() + r.AddRoute(&Route{Method: "GET", Path: "/baz", Code: testRoute}) + req := &http.Request{Method: "GET", URL: &url.URL{Path: "///////baz"}} + m, _ := r.Match(req) + + if m == nil { + t.Fatal() + } +} -- cgit 1.4.1