(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func TestUnescapeParameters(t *testing.T) { |
| 326 | tree := &node{} |
| 327 | |
| 328 | routes := [...]string{ |
| 329 | "/", |
| 330 | "/cmd/:tool/:sub", |
| 331 | "/cmd/:tool/", |
| 332 | "/src/*filepath", |
| 333 | "/search/:query", |
| 334 | "/files/:dir/*filepath", |
| 335 | "/info/:user/project/:project", |
| 336 | "/info/:user", |
| 337 | } |
| 338 | for _, route := range routes { |
| 339 | tree.addRoute(route, fakeHandler(route)) |
| 340 | } |
| 341 | |
| 342 | unescape := true |
| 343 | checkRequests(t, tree, testRequests{ |
| 344 | {"/", false, "/", nil}, |
| 345 | {"/cmd/test/", false, "/cmd/:tool/", Params{Param{Key: "tool", Value: "test"}}}, |
| 346 | {"/cmd/test", true, "", Params{Param{Key: "tool", Value: "test"}}}, |
| 347 | {"/src/some/file.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file.png"}}}, |
| 348 | {"/src/some/file+test.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file test.png"}}}, |
| 349 | {"/src/some/file++++%%%%test.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file++++%%%%test.png"}}}, |
| 350 | {"/src/some/file%2Ftest.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file/test.png"}}}, |
| 351 | {"/search/someth!ng+in+ünìcodé", false, "/search/:query", Params{Param{Key: "query", Value: "someth!ng in ünìcodé"}}}, |
| 352 | {"/info/gordon/project/go", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "gordon"}, Param{Key: "project", Value: "go"}}}, |
| 353 | {"/info/slash%2Fgordon", false, "/info/:user", Params{Param{Key: "user", Value: "slash/gordon"}}}, |
| 354 | {"/info/slash%2Fgordon/project/Project%20%231", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "slash/gordon"}, Param{Key: "project", Value: "Project #1"}}}, |
| 355 | {"/info/slash%%%%", false, "/info/:user", Params{Param{Key: "user", Value: "slash%%%%"}}}, |
| 356 | {"/info/slash%%%%2Fgordon/project/Project%%%%20%231", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "slash%%%%2Fgordon"}, Param{Key: "project", Value: "Project%%%%20%231"}}}, |
| 357 | }, unescape) |
| 358 | |
| 359 | checkPriorities(t, tree) |
| 360 | } |
| 361 | |
| 362 | func catchPanic(testFunc func()) (recv any) { |
| 363 | defer func() { |
nothing calls this directly
no test coverage detected