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

Function TestUseEncodedPath

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

Source from the content-addressed store, hash-verified

1541}
1542
1543func TestUseEncodedPath(t *testing.T) {
1544 r := NewRouter()
1545 r.UseEncodedPath()
1546
1547 tests := []routeTest{
1548 {
1549 title: "Router with useEncodedPath, URL with encoded slash does match",
1550 route: r.NewRoute().Path("/v1/{v1}/v2"),
1551 request: newRequest("GET", "http://localhost/v1/1%2F2/v2"),
1552 vars: map[string]string{"v1": "1%2F2"},
1553 host: "",
1554 path: "/v1/1%2F2/v2",
1555 pathTemplate: `/v1/{v1}/v2`,
1556 shouldMatch: true,
1557 },
1558 {
1559 title: "Router with useEncodedPath, URL with encoded slash doesn't match",
1560 route: r.NewRoute().Path("/v1/1/2/v2"),
1561 request: newRequest("GET", "http://localhost/v1/1%2F2/v2"),
1562 vars: map[string]string{"v1": "1%2F2"},
1563 host: "",
1564 path: "/v1/1%2F2/v2",
1565 pathTemplate: `/v1/1/2/v2`,
1566 shouldMatch: false,
1567 },
1568 }
1569
1570 for _, test := range tests {
1571 t.Run(test.title, func(t *testing.T) {
1572 testRoute(t, test)
1573 testTemplate(t, test)
1574 })
1575 }
1576}
1577
1578func TestWalkSingleDepth(t *testing.T) {
1579 r0 := NewRouter()

Callers

nothing calls this directly

Calls 7

UseEncodedPathMethod · 0.95
NewRouteMethod · 0.95
NewRouterFunction · 0.85
newRequestFunction · 0.85
testRouteFunction · 0.85
testTemplateFunction · 0.85
PathMethod · 0.45

Tested by

no test coverage detected