(t *testing.T)
| 1465 | } |
| 1466 | |
| 1467 | func 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/"), |
nothing calls this directly
no test coverage detected