|
|
|
@ -620,11 +620,52 @@ func TestStrictSlash(t *testing.T) { |
|
|
|
r.StrictSlash(true) |
|
|
|
r.StrictSlash(true) |
|
|
|
|
|
|
|
|
|
|
|
tests := []routeTest{ |
|
|
|
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", |
|
|
|
title: "Ignore StrictSlash for path prefix", |
|
|
|
route: r.NewRoute().PathPrefix("/static/"), |
|
|
|
route: r.NewRoute().PathPrefix("/static/"), |
|
|
|
request: newRequest("GET", "http://localhost/static/logo.png"), |
|
|
|
request: newRequest("GET", "http://localhost/static/logo.png"), |
|
|
|
vars: map[string]string{}, |
|
|
|
vars: map[string]string{}, |
|
|
|
|
|
|
|
host: "", |
|
|
|
path: "/static/", |
|
|
|
path: "/static/", |
|
|
|
shouldMatch: true, |
|
|
|
shouldMatch: true, |
|
|
|
shouldRedirect: false, |
|
|
|
shouldRedirect: false, |
|
|
|
|