MCPcopy
hub / github.com/gorilla/mux / TestStrictSlash

Function TestStrictSlash

mux_test.go:1467–1541  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1465}
1466
1467func TestStrictSlash(t *testing.T) {
1468 r := NewRouter()
1469 r.StrictSlash(true)
1470
1471 tests := []routeTest{
1472 {
1473 title: "Redirect path without slash",
1474 route: r.NewRoute().Path("/111/"),
1475 request: newRequest("GET", "http://localhost/111"),
1476 vars: map[string]string{},
1477 host: "",
1478 path: "/111/",
1479 shouldMatch: true,
1480 shouldRedirect: true,
1481 },
1482 {
1483 title: "Do not redirect path with slash",
1484 route: r.NewRoute().Path("/111/"),
1485 request: newRequest("GET", "http://localhost/111/"),
1486 vars: map[string]string{},
1487 host: "",
1488 path: "/111/",
1489 shouldMatch: true,
1490 shouldRedirect: false,
1491 },
1492 {
1493 title: "Redirect path with slash",
1494 route: r.NewRoute().Path("/111"),
1495 request: newRequest("GET", "http://localhost/111/"),
1496 vars: map[string]string{},
1497 host: "",
1498 path: "/111",
1499 shouldMatch: true,
1500 shouldRedirect: true,
1501 },
1502 {
1503 title: "Do not redirect path without slash",
1504 route: r.NewRoute().Path("/111"),
1505 request: newRequest("GET", "http://localhost/111"),
1506 vars: map[string]string{},
1507 host: "",
1508 path: "/111",
1509 shouldMatch: true,
1510 shouldRedirect: false,
1511 },
1512 {
1513 title: "Propagate StrictSlash to subrouters",
1514 route: r.NewRoute().PathPrefix("/static/").Subrouter().Path("/images/"),
1515 request: newRequest("GET", "http://localhost/static/images"),
1516 vars: map[string]string{},
1517 host: "",
1518 path: "/static/images/",
1519 shouldMatch: true,
1520 shouldRedirect: true,
1521 },
1522 {
1523 title: "Ignore StrictSlash for path prefix",
1524 route: r.NewRoute().PathPrefix("/static/"),

Callers

nothing calls this directly

Calls 10

StrictSlashMethod · 0.95
NewRouteMethod · 0.95
NewRouterFunction · 0.85
newRequestFunction · 0.85
testRouteFunction · 0.85
testTemplateFunction · 0.85
testUseEscapedRouteFunction · 0.85
SubrouterMethod · 0.80
PathMethod · 0.45
PathPrefixMethod · 0.45

Tested by

no test coverage detected