about summary refs log tree commit diff
path: root/router_test.go
diff options
context:
space:
mode:
authorFranck Cuny <franck@lumberjaph.net>2013-05-08 21:13:43 -0700
committerFranck Cuny <franck@lumberjaph.net>2013-05-08 21:13:43 -0700
commit7f419b0c2c86eb0b8c711b47392998e33e34bf9d (patch)
treecb464077fad4facbbeb65e2b58e66272b80d38cb /router_test.go
parentRename the package from mooh to router (diff)
downloadpath-router-7f419b0c2c86eb0b8c711b47392998e33e34bf9d.tar.gz
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.
Diffstat (limited to '')
-rw-r--r--router_test.go13
1 files changed, 13 insertions, 0 deletions
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()
+	}
+}