From 3509745ae8a2db852c51794a6f6e9f1e533e1632 Mon Sep 17 00:00:00 2001 From: Thomas ten Cate Date: Wed, 23 Apr 2014 19:27:53 +0200 Subject: [PATCH] Add tests for all four StrictSlash cases --- mux_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mux_test.go b/mux_test.go index a67efee..63bc491 100644 --- a/mux_test.go +++ b/mux_test.go @@ -620,11 +620,52 @@ func TestStrictSlash(t *testing.T) { r.StrictSlash(true) tests := []routeTest{ + { + title: "Redirect path without slash", + route: r.NewRoute().Path("/111/"), + request: newRequest("GET", "http://localhost/111"), + vars: map[string]string{}, + host: "", + path: "/111/", + shouldMatch: true, + shouldRedirect: true, + }, + { + title: "Do not redirect path with slash", + route: r.NewRoute().Path("/111/"), + request: newRequest("GET", "http://localhost/111/"), + vars: map[string]string{}, + host: "", + path: "/111/", + shouldMatch: true, + shouldRedirect: false, + }, + { + title: "Redirect path with slash", + route: r.NewRoute().Path("/111"), + request: newRequest("GET", "http://localhost/111/"), + vars: map[string]string{}, + host: "", + path: "/111", + shouldMatch: true, + shouldRedirect: true, + }, + { + title: "Do not redirect path without slash", + route: r.NewRoute().Path("/111"), + request: newRequest("GET", "http://localhost/111"), + vars: map[string]string{}, + host: "", + path: "/111", + shouldMatch: true, + shouldRedirect: false, + }, { title: "Ignore StrictSlash for path prefix", route: r.NewRoute().PathPrefix("/static/"), request: newRequest("GET", "http://localhost/static/logo.png"), vars: map[string]string{}, + host: "", path: "/static/", shouldMatch: true, shouldRedirect: false,